Skip to content

Commit

Permalink
Merge branch 'adjustments-for-cargo'
Browse files Browse the repository at this point in the history
  • Loading branch information
Byron committed Dec 7, 2023
2 parents a96956b + 6738955 commit 56588a9
Show file tree
Hide file tree
Showing 6 changed files with 75 additions and 6 deletions.
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
10 changes: 8 additions & 2 deletions gix-config/src/source.rs
Original file line number Diff line number Diff line change
Expand Up @@ -65,9 +65,15 @@ impl Source {
pub fn storage_location(self, env_var: &mut dyn FnMut(&str) -> Option<OsString>) -> Option<Cow<'static, Path>> {
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")
Expand Down
1 change: 1 addition & 0 deletions gix-config/tests/config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,5 @@ pub use gix_testtools::Result;

mod file;
mod parse;
mod source;
mod value;
64 changes: 64 additions & 0 deletions gix-config/tests/source/mod.rs
Original file line number Diff line number Diff line change
@@ -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"
);
}
}
2 changes: 0 additions & 2 deletions gix/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,6 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
- <csr-id-6cf73a44cbcd8bdca6a353cfd02d6237b1883b8c/> 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
- <csr-id-77686db3f91e16fa6657dbae2182ec72e88d3fd0/> `revision::Spec::path_and_mode()`
Provide additional information about revspecs for use with
worktree filters.
Expand Down
3 changes: 1 addition & 2 deletions gix/src/revision/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@ pub use gix_revision as plumbing;

///
pub mod walk;
use crate::bstr::BString;
pub use walk::iter::Walk;

///
Expand All @@ -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 `@:<path>` or `@..@~1:<path>`.
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<gix_ref::Reference>,
/// The second name of a reference as seen while parsing a `RevSpec`, for completeness.
Expand Down

0 comments on commit 56588a9

Please sign in to comment.