summaryrefslogtreecommitdiffstats
path: root/vendor/gix/src/config/cache/access.rs
diff options
context:
space:
mode:
authorDaniel Baumann <daniel.baumann@progress-linux.org>2024-06-19 09:26:03 +0000
committerDaniel Baumann <daniel.baumann@progress-linux.org>2024-06-19 09:26:03 +0000
commit9918693037dce8aa4bb6f08741b6812923486c18 (patch)
tree21d2b40bec7e6a7ea664acee056eb3d08e15a1cf /vendor/gix/src/config/cache/access.rs
parentReleasing progress-linux version 1.75.0+dfsg1-5~progress7.99u1. (diff)
downloadrustc-9918693037dce8aa4bb6f08741b6812923486c18.tar.xz
rustc-9918693037dce8aa4bb6f08741b6812923486c18.zip
Merging upstream version 1.76.0+dfsg1.
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'vendor/gix/src/config/cache/access.rs')
-rw-r--r--vendor/gix/src/config/cache/access.rs121
1 files changed, 106 insertions, 15 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());