From 11c9f66523011064e5e82d3b32713a7f4643809d Mon Sep 17 00:00:00 2001 From: Sebastian Thiel Date: Thu, 7 Dec 2023 07:20:21 +0100 Subject: [PATCH 1/4] remove extra-lines from changelog (#1158) --- gix/CHANGELOG.md | 2 -- 1 file changed, 2 deletions(-) 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. From 082e6ed38e5a40f10f2a64c278b8a01dd24bba27 Mon Sep 17 00:00:00 2001 From: Sebastian Thiel Date: Thu, 7 Dec 2023 07:26:05 +0100 Subject: [PATCH 2/4] Add `blob-diff` to list of major features. It's hard enough to properly implement it, and by now it seemingly fully supports enough features to be very faithful to the original. --- README.md | 1 + 1 file changed, 1 insertion(+) 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 From ec0211afa6313d0f640dc4cbb4c0988ad27009df Mon Sep 17 00:00:00 2001 From: Sebastian Thiel Date: Thu, 7 Dec 2023 09:31:07 +0100 Subject: [PATCH 3/4] fix import/prevent warning --- gix/src/revision/mod.rs | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) 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. From 6738955949d82a66c070dcb65e368652898bd1d2 Mon Sep 17 00:00:00 2001 From: Sebastian Thiel Date: Thu, 7 Dec 2023 09:23:40 +0100 Subject: [PATCH 4/4] feat: `GIT_CONFIG_NOSYSTEM` now also affects the installation directory. It makes sense to consider it part of the 'system', and allows for proper isolation of `gix` operations, for example in tests. This is also a fix, as previously it checked for `...NO_SYSTEM`, instead of `NOSYSTEM`. --- gix-config/src/source.rs | 10 ++++-- gix-config/tests/config.rs | 1 + gix-config/tests/source/mod.rs | 64 ++++++++++++++++++++++++++++++++++ 3 files changed, 73 insertions(+), 2 deletions(-) create mode 100644 gix-config/tests/source/mod.rs 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" + ); + } +}