diff options
Diffstat (limited to 'vendor/gix/src/config/cache')
-rw-r--r-- | vendor/gix/src/config/cache/access.rs | 121 | ||||
-rw-r--r-- | vendor/gix/src/config/cache/init.rs | 68 | ||||
-rw-r--r-- | vendor/gix/src/config/cache/util.rs | 12 |
3 files changed, 181 insertions, 20 deletions
diff --git a/vendor/gix/src/config/cache/access.rs b/vendor/gix/src/config/cache/access.rs index 3e763c028..464a0bf4d 100644 --- a/vendor/gix/src/config/cache/access.rs +++ b/vendor/gix/src/config/cache/access.rs @@ -20,8 +20,7 @@ use crate::{ impl Cache { #[cfg(feature = "blob-diff")] pub(crate) fn diff_algorithm(&self) -> Result<gix_diff::blob::Algorithm, config::diff::algorithm::Error> { - use crate::config::cache::util::ApplyLeniencyDefault; - use crate::config::diff::algorithm::Error; + use crate::config::{cache::util::ApplyLeniencyDefault, diff::algorithm::Error}; self.diff_algorithm .get_or_try_init(|| { let name = self @@ -39,6 +38,97 @@ impl Cache { .copied() } + #[cfg(feature = "blob-diff")] + pub(crate) fn diff_drivers(&self) -> Result<Vec<gix_diff::blob::Driver>, config::diff::drivers::Error> { + use crate::config::cache::util::ApplyLeniencyDefault; + let mut out = Vec::<gix_diff::blob::Driver>::new(); + for section in self + .resolved + .sections_by_name("diff") + .into_iter() + .flatten() + .filter(|s| (self.filter_config_section)(s.meta())) + { + let Some(name) = section.header().subsection_name().filter(|n| !n.is_empty()) else { + continue; + }; + + let driver = match out.iter_mut().find(|d| d.name == name) { + Some(existing) => existing, + None => { + out.push(gix_diff::blob::Driver { + name: name.into(), + ..Default::default() + }); + out.last_mut().expect("just pushed") + } + }; + + if let Some(binary) = section.value_implicit("binary") { + driver.is_binary = config::tree::Diff::DRIVER_BINARY + .try_into_binary(binary) + .with_leniency(self.lenient_config) + .map_err(|err| config::diff::drivers::Error { + name: driver.name.clone(), + attribute: "binary", + source: Box::new(err), + })?; + } + if let Some(command) = section.value(config::tree::Diff::DRIVER_COMMAND.name) { + driver.command = command.into_owned().into(); + } + if let Some(textconv) = section.value(config::tree::Diff::DRIVER_TEXTCONV.name) { + driver.binary_to_text_command = textconv.into_owned().into(); + } + if let Some(algorithm) = section.value("algorithm") { + driver.algorithm = config::tree::Diff::DRIVER_ALGORITHM + .try_into_algorithm(algorithm) + .or_else(|err| match err { + config::diff::algorithm::Error::Unimplemented { .. } if self.lenient_config => { + Ok(gix_diff::blob::Algorithm::Histogram) + } + err => Err(err), + }) + .with_lenient_default(self.lenient_config) + .map_err(|err| config::diff::drivers::Error { + name: driver.name.clone(), + attribute: "algorithm", + source: Box::new(err), + })? + .into(); + } + } + Ok(out) + } + + #[cfg(feature = "blob-diff")] + pub(crate) fn diff_pipeline_options( + &self, + ) -> Result<gix_diff::blob::pipeline::Options, config::diff::pipeline_options::Error> { + Ok(gix_diff::blob::pipeline::Options { + large_file_threshold_bytes: self.big_file_threshold()?, + fs: self.fs_capabilities()?, + }) + } + + #[cfg(feature = "blob-diff")] + pub(crate) fn diff_renames(&self) -> Result<Option<crate::diff::Rewrites>, crate::diff::new_rewrites::Error> { + self.diff_renames + .get_or_try_init(|| crate::diff::new_rewrites(&self.resolved, self.lenient_config)) + .copied() + } + + #[cfg(feature = "blob-diff")] + pub(crate) fn big_file_threshold(&self) -> Result<u64, config::unsigned_integer::Error> { + Ok(self + .resolved + .integer_by_key("core.bigFileThreshold") + .map(|number| Core::BIG_FILE_THRESHOLD.try_into_u64(number)) + .transpose() + .with_leniency(self.lenient_config)? + .unwrap_or(512 * 1024 * 1024)) + } + /// Returns a user agent for use with servers. #[cfg(any(feature = "async-network-client", feature = "blocking-network-client"))] pub(crate) fn user_agent_tuple(&self) -> (&'static str, Option<Cow<'static, str>>) { @@ -54,6 +144,18 @@ impl Cache { ("agent", Some(gix_protocol::agent(agent).into())) } + /// Return `true` if packet-tracing is enabled. Lenient and defaults to `false`. + #[cfg(any(feature = "async-network-client", feature = "blocking-network-client"))] + pub(crate) fn trace_packet(&self) -> bool { + use config::tree::Gitoxide; + + use crate::config::tree::Section; + self.resolved + .boolean(Gitoxide.name(), None, Gitoxide::TRACE_PACKET.name()) + .and_then(Result::ok) + .unwrap_or_default() + } + pub(crate) fn personas(&self) -> &identity::Personas { self.personas .get_or_init(|| identity::Personas::from_config_and_env(&self.resolved)) @@ -81,17 +183,6 @@ impl Cache { }) } - #[cfg(feature = "blob-diff")] - pub(crate) fn diff_renames( - &self, - ) -> Result<Option<crate::object::tree::diff::Rewrites>, crate::object::tree::diff::rewrites::Error> { - self.diff_renames - .get_or_try_init(|| { - crate::object::tree::diff::Rewrites::try_from_config(&self.resolved, self.lenient_config) - }) - .copied() - } - /// Returns (file-timeout, pack-refs timeout) pub(crate) fn lock_timeout( &self, @@ -189,8 +280,8 @@ impl Cache { )?; let capabilities = self.fs_capabilities()?; let filters = { - let collection = Default::default(); - let mut filters = gix_filter::Pipeline::new(&collection, crate::filter::Pipeline::options(repo)?); + let mut filters = + gix_filter::Pipeline::new(repo.command_context()?, crate::filter::Pipeline::options(repo)?); if let Ok(mut head) = repo.head() { let ctx = filters.driver_context_mut(); ctx.ref_name = head.referent_name().map(|name| name.as_bstr().to_owned()); diff --git a/vendor/gix/src/config/cache/init.rs b/vendor/gix/src/config/cache/init.rs index 3c482b154..faf3cc8de 100644 --- a/vendor/gix/src/config/cache/init.rs +++ b/vendor/gix/src/config/cache/init.rs @@ -9,7 +9,7 @@ use crate::{ config, config::{ cache::util::ApplyLeniency, - tree::{gitoxide, Core, Http}, + tree::{gitoxide, Core, Gitoxide, Http}, Cache, }, open, @@ -143,6 +143,7 @@ impl Cache { use util::config_bool; let reflog = util::query_refupdates(&config, lenient_config)?; + let refs_namespace = util::query_refs_namespace(&config, lenient_config)?; let ignore_case = config_bool(&config, &Core::IGNORE_CASE, "core.ignoreCase", false, lenient_config)?; let use_multi_pack_index = config_bool( &config, @@ -166,6 +167,7 @@ impl Cache { pack_cache_bytes, object_cache_bytes, reflog, + refs_namespace, is_bare, ignore_case, hex_len, @@ -222,10 +224,12 @@ impl Cache { self.object_kind_hint = object_kind_hint; } let reflog = util::query_refupdates(config, self.lenient_config)?; + let refs_namespace = util::query_refs_namespace(config, self.lenient_config)?; self.hex_len = hex_len; self.ignore_case = ignore_case; self.reflog = reflog; + self.refs_namespace = refs_namespace; self.user_agent = Default::default(); self.personas = Default::default(); @@ -298,6 +302,7 @@ impl crate::Repository { fn apply_changed_values(&mut self) { self.refs.write_reflog = util::reflog_or_default(self.config.reflog, self.work_dir().is_some()); + self.refs.namespace = self.config.refs_namespace.clone(); } } @@ -339,6 +344,15 @@ fn apply_environment_overrides( ), ( "gitoxide", + None, + git_prefix, + &[{ + let key = &Gitoxide::TRACE_PACKET; + (env(key), key.name) + }], + ), + ( + "gitoxide", Some(Cow::Borrowed("https".into())), http_transport, &[ @@ -377,6 +391,30 @@ fn apply_environment_overrides( ), ( "gitoxide", + Some(Cow::Borrowed("http".into())), + git_prefix, + &[{ + let key = &gitoxide::Http::SSL_NO_VERIFY; + (env(key), key.name) + }], + ), + ( + "gitoxide", + Some(Cow::Borrowed("credentials".into())), + git_prefix, + &[ + { + let key = &gitoxide::Credentials::TERMINAL_PROMPT; + (env(key), key.name) + }, + { + let key = &gitoxide::Credentials::HELPER_STDERR; + (env(key), key.name) + }, + ], + ), + ( + "gitoxide", Some(Cow::Borrowed("committer".into())), identity, &[ @@ -394,10 +432,20 @@ fn apply_environment_overrides( "gitoxide", Some(Cow::Borrowed("core".into())), git_prefix, - &[{ - let key = &gitoxide::Core::SHALLOW_FILE; - (env(key), key.name) - }], + &[ + { + let key = &gitoxide::Core::SHALLOW_FILE; + (env(key), key.name) + }, + { + let key = &gitoxide::Core::REFS_NAMESPACE; + (env(key), key.name) + }, + { + let key = &gitoxide::Core::EXTERNAL_COMMAND_STDERR; + (env(key), key.name) + }, + ], ), ( "gitoxide", @@ -500,6 +548,16 @@ fn apply_environment_overrides( (env(key), key.name) }], ), + #[cfg(feature = "blob-diff")] + ( + "diff", + None, + git_prefix, + &[{ + let key = &config::tree::Diff::EXTERNAL; + (env(key), key.name) + }], + ), ] { let mut section = env_override .new_section(section_name, subsection_name) diff --git a/vendor/gix/src/config/cache/util.rs b/vendor/gix/src/config/cache/util.rs index 4032b2cb1..4c1d6c693 100644 --- a/vendor/gix/src/config/cache/util.rs +++ b/vendor/gix/src/config/cache/util.rs @@ -55,6 +55,18 @@ pub(crate) fn query_refupdates( .map_err(Into::into) } +pub(crate) fn query_refs_namespace( + config: &gix_config::File<'static>, + lenient_config: bool, +) -> Result<Option<gix_ref::Namespace>, config::refs_namespace::Error> { + let key = "gitoxide.core.refsNamespace"; + config + .string_by_key(key) + .map(|ns| gitoxide::Core::REFS_NAMESPACE.try_into_refs_namespace(ns)) + .transpose() + .with_leniency(lenient_config) +} + pub(crate) fn reflog_or_default( config_reflog: Option<gix_ref::store::WriteReflog>, has_worktree: bool, |