diff --git a/README.md b/README.md index 64adfb4c184..831459f0005 100644 --- a/README.md +++ b/README.md @@ -42,6 +42,7 @@ What follows is a high-level list of features and those which are planned: * [ ] push * [ ] reset * [ ] status +* [x] blob-diff * [ ] merge * [ ] rebase * [ ] commit diff --git a/gix-config/src/source.rs b/gix-config/src/source.rs index d8ca60db4ba..18d396e8b2c 100644 --- a/gix-config/src/source.rs +++ b/gix-config/src/source.rs @@ -65,9 +65,15 @@ impl Source { pub fn storage_location(self, env_var: &mut dyn FnMut(&str) -> Option) -> Option> { use Source::*; match self { - GitInstallation => gix_path::env::installation_config().map(Into::into), + GitInstallation => { + if env_var("GIT_CONFIG_NOSYSTEM").is_some() { + None + } else { + gix_path::env::installation_config().map(Into::into) + } + } System => { - if env_var("GIT_CONFIG_NO_SYSTEM").is_some() { + if env_var("GIT_CONFIG_NOSYSTEM").is_some() { None } else { env_var("GIT_CONFIG_SYSTEM") diff --git a/gix-config/tests/config.rs b/gix-config/tests/config.rs index 7107bca8bad..fe1b3dec068 100644 --- a/gix-config/tests/config.rs +++ b/gix-config/tests/config.rs @@ -2,4 +2,5 @@ pub use gix_testtools::Result; mod file; mod parse; +mod source; mod value; diff --git a/gix-config/tests/source/mod.rs b/gix-config/tests/source/mod.rs new file mode 100644 index 00000000000..9dfd040b12b --- /dev/null +++ b/gix-config/tests/source/mod.rs @@ -0,0 +1,64 @@ +use gix_config::Source; +use std::path::Path; + +#[test] +fn git_config_no_system() { + assert_eq!( + Source::GitInstallation.storage_location(&mut |name| { + assert_eq!( + name, "GIT_CONFIG_NOSYSTEM", + "it only checks this var, and if set, nothing else" + ); + Some("1".into()) + }), + None + ); + assert_eq!( + Source::System.storage_location(&mut |name| { + assert_eq!( + name, "GIT_CONFIG_NOSYSTEM", + "it only checks this var, and if set, nothing else" + ); + Some("1".into()) + }), + None + ); +} + +#[test] +fn git_config_system() { + assert_eq!( + Source::System + .storage_location(&mut |name| { + match name { + "GIT_CONFIG_NOSYSTEM" => None, + "GIT_CONFIG_SYSTEM" => Some("alternative".into()), + unexpected => unreachable!("unexpected env var: {unexpected}"), + } + }) + .expect("set") + .as_ref(), + Path::new("alternative"), + "we respect the system config variable for overrides" + ); +} + +#[test] +fn git_config_global() { + for source in [Source::Git, Source::User] { + assert_eq!( + source + .storage_location(&mut |name| { + assert_eq!( + name, "GIT_CONFIG_GLOBAL", + "it only checks this var, and if set, nothing else" + ); + Some("alternative".into()) + }) + .expect("set") + .as_ref(), + Path::new("alternative"), + "we respect the global config variable for 'git' overrides" + ); + } +} diff --git a/gix/CHANGELOG.md b/gix/CHANGELOG.md index 8eca00d83c8..ae2fe258541 100644 --- a/gix/CHANGELOG.md +++ b/gix/CHANGELOG.md @@ -15,8 +15,6 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 - use `gitoxide.credentials.helperStderr` key to control how stderr is handled with helpers. That way users can configure each repository instance according to their needs, with which includes disabling the `stderr` of credential helpers. - - Please enter the message for your patch. Lines starting with - `revision::Spec::path_and_mode()` Provide additional information about revspecs for use with worktree filters. diff --git a/gix/src/revision/mod.rs b/gix/src/revision/mod.rs index 62fe72dd3f6..9bd23b994bd 100644 --- a/gix/src/revision/mod.rs +++ b/gix/src/revision/mod.rs @@ -7,7 +7,6 @@ pub use gix_revision as plumbing; /// pub mod walk; -use crate::bstr::BString; pub use walk::iter::Walk; /// @@ -24,7 +23,7 @@ pub mod spec; pub struct Spec<'repo> { pub(crate) inner: gix_revision::Spec, /// The path we encountered in the revspec, like `@:` or `@..@~1:`. - pub(crate) path: Option<(BString, gix_object::tree::EntryMode)>, + pub(crate) path: Option<(crate::bstr::BString, gix_object::tree::EntryMode)>, /// The first name of a reference as seen while parsing a `RevSpec`, for completeness. pub(crate) first_ref: Option, /// The second name of a reference as seen while parsing a `RevSpec`, for completeness.