summaryrefslogtreecommitdiffstats
path: root/vendor/gix/src/config/cache/init.rs
diff options
context:
space:
mode:
authorDaniel Baumann <daniel.baumann@progress-linux.org>2024-05-18 02:49:50 +0000
committerDaniel Baumann <daniel.baumann@progress-linux.org>2024-05-18 02:49:50 +0000
commit9835e2ae736235810b4ea1c162ca5e65c547e770 (patch)
tree3fcebf40ed70e581d776a8a4c65923e8ec20e026 /vendor/gix/src/config/cache/init.rs
parentReleasing progress-linux version 1.70.0+dfsg2-1~progress7.99u1. (diff)
downloadrustc-9835e2ae736235810b4ea1c162ca5e65c547e770.tar.xz
rustc-9835e2ae736235810b4ea1c162ca5e65c547e770.zip
Merging upstream version 1.71.1+dfsg1.
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'vendor/gix/src/config/cache/init.rs')
-rw-r--r--vendor/gix/src/config/cache/init.rs71
1 files changed, 48 insertions, 23 deletions
diff --git a/vendor/gix/src/config/cache/init.rs b/vendor/gix/src/config/cache/init.rs
index dc76f78bb..ee20e0354 100644
--- a/vendor/gix/src/config/cache/init.rs
+++ b/vendor/gix/src/config/cache/init.rs
@@ -1,5 +1,5 @@
#![allow(clippy::result_large_err)]
-use std::borrow::Cow;
+use std::{borrow::Cow, ffi::OsString};
use gix_sec::Permission;
@@ -12,7 +12,7 @@ use crate::{
tree::{gitoxide, Core, Http},
Cache,
},
- repository,
+ open,
};
/// Initialization
@@ -32,23 +32,24 @@ impl Cache {
filter_config_section: fn(&gix_config::file::Metadata) -> bool,
git_install_dir: Option<&std::path::Path>,
home: Option<&std::path::Path>,
- repository::permissions::Environment {
+ environment @ open::permissions::Environment {
git_prefix,
- home: home_env,
- xdg_config_home: xdg_config_home_env,
ssh_prefix: _,
+ xdg_config_home: _,
+ home: _,
http_transport,
identity,
objects,
- }: repository::permissions::Environment,
- repository::permissions::Config {
+ }: open::permissions::Environment,
+ attributes: open::permissions::Attributes,
+ open::permissions::Config {
git_binary: use_installation,
system: use_system,
git: use_git,
user: use_user,
env: use_env,
includes: use_includes,
- }: repository::permissions::Config,
+ }: open::permissions::Config,
lenient_config: bool,
api_config_overrides: &[BString],
cli_config_overrides: &[BString],
@@ -65,12 +66,10 @@ impl Cache {
} else {
gix_config::file::includes::Options::no_follow()
},
- ..util::base_options(lossy)
+ ..util::base_options(lossy, lenient_config)
};
let config = {
- let home_env = &home_env;
- let xdg_config_home_env = &xdg_config_home_env;
let git_prefix = &git_prefix;
let metas = [
gix_config::source::Kind::GitInstallation,
@@ -88,15 +87,7 @@ impl Cache {
_ => {}
}
source
- .storage_location(&mut |name| {
- match name {
- git_ if git_.starts_with("GIT_") => Some(git_prefix),
- "XDG_CONFIG_HOME" => Some(xdg_config_home_env),
- "HOME" => Some(home_env),
- _ => None,
- }
- .and_then(|perm| perm.check_opt(name).and_then(std::env::var_os))
- })
+ .storage_location(&mut Self::make_source_env(environment))
.map(|p| (source, p.into_owned()))
})
.map(|(source, path)| gix_config::file::Metadata {
@@ -118,7 +109,7 @@ impl Cache {
)
.map_err(|err| match err {
gix_config::file::init::from_paths::Error::Init(err) => Error::from(err),
- gix_config::file::init::from_paths::Error::Io(err) => err.into(),
+ gix_config::file::init::from_paths::Error::Io { source, path } => Error::Io { source, path },
})?
.unwrap_or_default();
@@ -175,9 +166,9 @@ impl Cache {
ignore_case,
hex_len,
filter_config_section,
- xdg_config_home_env,
- home_env,
+ environment,
lenient_config,
+ attributes,
user_agent: Default::default(),
personas: Default::default(),
url_rewrite: Default::default(),
@@ -240,6 +231,31 @@ impl Cache {
Ok(())
}
+
+ pub(crate) fn make_source_env(
+ crate::open::permissions::Environment {
+ xdg_config_home,
+ git_prefix,
+ home,
+ ..
+ }: open::permissions::Environment,
+ ) -> impl FnMut(&str) -> Option<OsString> {
+ move |name| {
+ match name {
+ git_ if git_.starts_with("GIT_") => Some(git_prefix),
+ "XDG_CONFIG_HOME" => Some(xdg_config_home),
+ "HOME" => {
+ return if home.is_allowed() {
+ gix_path::env::home_dir().map(Into::into)
+ } else {
+ None
+ }
+ }
+ _ => None,
+ }
+ .and_then(|perm| perm.check_opt(name).and_then(gix_path::env::var))
+ }
+ }
}
impl crate::Repository {
@@ -349,6 +365,15 @@ fn apply_environment_overrides(
),
(
"gitoxide",
+ Some(Cow::Borrowed("core".into())),
+ git_prefix,
+ &[{
+ let key = &gitoxide::Core::SHALLOW_FILE;
+ (env(key), key.name)
+ }],
+ ),
+ (
+ "gitoxide",
Some(Cow::Borrowed("author".into())),
identity,
&[