summaryrefslogtreecommitdiffstats
path: root/vendor/gix/src/config/tree/sections
diff options
context:
space:
mode:
Diffstat (limited to 'vendor/gix/src/config/tree/sections')
-rw-r--r--vendor/gix/src/config/tree/sections/core.rs6
-rw-r--r--vendor/gix/src/config/tree/sections/fetch.rs68
-rw-r--r--vendor/gix/src/config/tree/sections/gitoxide.rs17
-rw-r--r--vendor/gix/src/config/tree/sections/index.rs10
-rw-r--r--vendor/gix/src/config/tree/sections/mod.rs5
-rw-r--r--vendor/gix/src/config/tree/sections/protocol.rs54
6 files changed, 149 insertions, 11 deletions
diff --git a/vendor/gix/src/config/tree/sections/core.rs b/vendor/gix/src/config/tree/sections/core.rs
index 6ea0580e1..93d2fcd01 100644
--- a/vendor/gix/src/config/tree/sections/core.rs
+++ b/vendor/gix/src/config/tree/sections/core.rs
@@ -36,7 +36,7 @@ impl Core {
LogAllRefUpdates::new_with_validate("logAllRefUpdates", &config::Tree::CORE, validate::LogAllRefUpdates);
/// The `core.precomposeUnicode` key.
///
- /// Needs application to use [env::args_os][crate::env::args_os()] to conform all input paths before they are used.
+ /// Needs application to use [`env::args_os`][crate::env::args_os()] to conform all input paths before they are used.
pub const PRECOMPOSE_UNICODE: keys::Boolean = keys::Boolean::new_boolean("precomposeUnicode", &config::Tree::CORE)
.with_note("application needs to conform all program input by using gix::env::args_os()");
/// The `core.repositoryFormatVersion` key.
@@ -63,6 +63,9 @@ impl Core {
/// The `core.sshCommand` key.
pub const SSH_COMMAND: keys::Executable = keys::Executable::new_executable("sshCommand", &config::Tree::CORE)
.with_environment_override("GIT_SSH_COMMAND");
+ /// The `core.useReplaceRefs` key.
+ pub const USE_REPLACE_REFS: keys::Boolean = keys::Boolean::new_boolean("useReplaceRefs", &config::Tree::CORE)
+ .with_environment_override("GIT_NO_REPLACE_OBJECTS");
}
impl Section for Core {
@@ -92,6 +95,7 @@ impl Section for Core {
&Self::EXCLUDES_FILE,
&Self::ATTRIBUTES_FILE,
&Self::SSH_COMMAND,
+ &Self::USE_REPLACE_REFS,
]
}
}
diff --git a/vendor/gix/src/config/tree/sections/fetch.rs b/vendor/gix/src/config/tree/sections/fetch.rs
new file mode 100644
index 000000000..117cabfd2
--- /dev/null
+++ b/vendor/gix/src/config/tree/sections/fetch.rs
@@ -0,0 +1,68 @@
+use crate::{
+ config,
+ config::tree::{keys, Fetch, Key, Section},
+};
+
+impl Fetch {
+ /// The `fetch.negotiationAlgorithm` key.
+ pub const NEGOTIATION_ALGORITHM: NegotiationAlgorithm = NegotiationAlgorithm::new_with_validate(
+ "negotiationAlgorithm",
+ &config::Tree::FETCH,
+ validate::NegotiationAlgorithm,
+ );
+}
+
+impl Section for Fetch {
+ fn name(&self) -> &str {
+ "fetch"
+ }
+
+ fn keys(&self) -> &[&dyn Key] {
+ &[&Self::NEGOTIATION_ALGORITHM]
+ }
+}
+
+/// The `fetch.negotiationAlgorithm` key.
+pub type NegotiationAlgorithm = keys::Any<validate::NegotiationAlgorithm>;
+
+mod algorithm {
+ use std::borrow::Cow;
+
+ use gix_object::bstr::ByteSlice;
+
+ use crate::{
+ bstr::BStr,
+ config::{key::GenericErrorWithValue, tree::sections::fetch::NegotiationAlgorithm},
+ remote::fetch::negotiate,
+ };
+
+ impl NegotiationAlgorithm {
+ /// Derive the negotiation algorithm identified by `name`, case-sensitively.
+ pub fn try_into_negotiation_algorithm(
+ &'static self,
+ name: Cow<'_, BStr>,
+ ) -> Result<negotiate::Algorithm, GenericErrorWithValue> {
+ Ok(match name.as_ref().as_bytes() {
+ b"noop" => negotiate::Algorithm::Noop,
+ b"consecutive" | b"default" => negotiate::Algorithm::Consecutive,
+ b"skipping" => negotiate::Algorithm::Skipping,
+ _ => return Err(GenericErrorWithValue::from_value(self, name.into_owned())),
+ })
+ }
+ }
+}
+
+mod validate {
+ use crate::{
+ bstr::BStr,
+ config::tree::{keys, Fetch},
+ };
+
+ pub struct NegotiationAlgorithm;
+ impl keys::Validate for NegotiationAlgorithm {
+ fn validate(&self, value: &BStr) -> Result<(), Box<dyn std::error::Error + Send + Sync + 'static>> {
+ Fetch::NEGOTIATION_ALGORITHM.try_into_negotiation_algorithm(value.into())?;
+ Ok(())
+ }
+ }
+}
diff --git a/vendor/gix/src/config/tree/sections/gitoxide.rs b/vendor/gix/src/config/tree/sections/gitoxide.rs
index 7d60f1287..f07d494fb 100644
--- a/vendor/gix/src/config/tree/sections/gitoxide.rs
+++ b/vendor/gix/src/config/tree/sections/gitoxide.rs
@@ -67,6 +67,11 @@ mod subsections {
pub struct Core;
impl Core {
+ /// The `gitoxide.core.defaultPackCacheMemoryLimit` key.
+ pub const DEFAULT_PACK_CACHE_MEMORY_LIMIT: keys::UnsignedInteger =
+ keys::UnsignedInteger::new_unsigned_integer("defaultPackCacheMemoryLimit", &Gitoxide::CORE).with_note(
+ "If unset, we default to 96MB memory cap for the default 64 slot LRU cache for object deltas.",
+ );
/// The `gitoxide.core.useNsec` key.
pub const USE_NSEC: keys::Boolean = keys::Boolean::new_boolean("useNsec", &Gitoxide::CORE)
.with_note("A runtime version of the USE_NSEC build flag.");
@@ -89,7 +94,12 @@ mod subsections {
}
fn keys(&self) -> &[&dyn Key] {
- &[&Self::USE_NSEC, &Self::USE_STDEV, &Self::SHALLOW_FILE]
+ &[
+ &Self::DEFAULT_PACK_CACHE_MEMORY_LIMIT,
+ &Self::USE_NSEC,
+ &Self::USE_STDEV,
+ &Self::SHALLOW_FILE,
+ ]
}
fn parent(&self) -> Option<&dyn Section> {
@@ -307,8 +317,7 @@ mod subsections {
.with_note("If unset or 0, there is no object cache")
.with_environment_override("GITOXIDE_OBJECT_CACHE_MEMORY");
/// The `gitoxide.objects.noReplace` key.
- pub const NO_REPLACE: keys::Boolean = keys::Boolean::new_boolean("noReplace", &Gitoxide::OBJECTS)
- .with_environment_override("GIT_NO_REPLACE_OBJECTS");
+ pub const NO_REPLACE: keys::Boolean = keys::Boolean::new_boolean("noReplace", &Gitoxide::OBJECTS);
/// The `gitoxide.objects.replaceRefBase` key.
pub const REPLACE_REF_BASE: keys::Any =
keys::Any::new("replaceRefBase", &Gitoxide::OBJECTS).with_environment_override("GIT_REPLACE_REF_BASE");
@@ -320,7 +329,7 @@ mod subsections {
}
fn keys(&self) -> &[&dyn Key] {
- &[&Self::CACHE_LIMIT, &Self::NO_REPLACE, &Self::REPLACE_REF_BASE]
+ &[&Self::CACHE_LIMIT, &Self::REPLACE_REF_BASE]
}
fn parent(&self) -> Option<&dyn Section> {
diff --git a/vendor/gix/src/config/tree/sections/index.rs b/vendor/gix/src/config/tree/sections/index.rs
index d03322247..08f7ec1bd 100644
--- a/vendor/gix/src/config/tree/sections/index.rs
+++ b/vendor/gix/src/config/tree/sections/index.rs
@@ -13,12 +13,14 @@ impl Index {
pub type IndexThreads = keys::Any<validate::IndexThreads>;
mod index_threads {
- use crate::bstr::BStr;
- use crate::config;
- use crate::config::key::GenericErrorWithValue;
- use crate::config::tree::index::IndexThreads;
use std::borrow::Cow;
+ use crate::{
+ bstr::BStr,
+ config,
+ config::{key::GenericErrorWithValue, tree::index::IndexThreads},
+ };
+
impl IndexThreads {
/// Parse `value` into the amount of threads to use, with `1` being single-threaded, or `0` indicating
/// to select the amount of threads, with any other number being the specific amount of threads to use.
diff --git a/vendor/gix/src/config/tree/sections/mod.rs b/vendor/gix/src/config/tree/sections/mod.rs
index 9f0a50c93..ebf24a8b7 100644
--- a/vendor/gix/src/config/tree/sections/mod.rs
+++ b/vendor/gix/src/config/tree/sections/mod.rs
@@ -45,6 +45,11 @@ pub mod diff;
pub struct Extensions;
pub mod extensions;
+/// The `fetch` top-level section.
+#[derive(Copy, Clone, Default)]
+pub struct Fetch;
+pub mod fetch;
+
/// The `gitoxide` top-level section.
#[derive(Copy, Clone, Default)]
pub struct Gitoxide;
diff --git a/vendor/gix/src/config/tree/sections/protocol.rs b/vendor/gix/src/config/tree/sections/protocol.rs
index 58e907b0f..a0510f2b8 100644
--- a/vendor/gix/src/config/tree/sections/protocol.rs
+++ b/vendor/gix/src/config/tree/sections/protocol.rs
@@ -6,6 +6,8 @@ use crate::{
impl Protocol {
/// The `protocol.allow` key.
pub const ALLOW: Allow = Allow::new_with_validate("allow", &config::Tree::PROTOCOL, validate::Allow);
+ /// The `protocol.version` key.
+ pub const VERSION: Version = Version::new_with_validate("version", &config::Tree::PROTOCOL, validate::Version);
/// The `protocol.<name>` subsection
pub const NAME_PARAMETER: NameParameter = NameParameter;
@@ -14,6 +16,9 @@ impl Protocol {
/// The `protocol.allow` key type.
pub type Allow = keys::Any<validate::Allow>;
+/// The `protocol.version` key.
+pub type Version = keys::Any<validate::Version>;
+
#[cfg(any(feature = "blocking-network-client", feature = "async-network-client"))]
mod allow {
use std::borrow::Cow;
@@ -39,7 +44,7 @@ mod allow {
pub struct NameParameter;
impl NameParameter {
- /// The `credential.<url>.helper` key.
+ /// The `protocol.<name>.allow` key.
pub const ALLOW: Allow = Allow::new_with_validate("allow", &Protocol::NAME_PARAMETER, validate::Allow);
}
@@ -63,7 +68,7 @@ impl Section for Protocol {
}
fn keys(&self) -> &[&dyn Key] {
- &[&Self::ALLOW]
+ &[&Self::ALLOW, &Self::VERSION]
}
fn sub_sections(&self) -> &[&dyn Section] {
@@ -71,6 +76,38 @@ impl Section for Protocol {
}
}
+mod key_impls {
+ impl super::Version {
+ /// Convert `value` into the corresponding protocol version, possibly applying the correct default.
+ #[cfg(any(feature = "blocking-network-client", feature = "async-network-client"))]
+ pub fn try_into_protocol_version(
+ &'static self,
+ value: Option<Result<i64, gix_config::value::Error>>,
+ ) -> Result<gix_protocol::transport::Protocol, crate::config::key::GenericErrorWithValue> {
+ let value = match value {
+ None => return Ok(gix_protocol::transport::Protocol::V2),
+ Some(v) => v,
+ };
+ Ok(match value {
+ Ok(0) => gix_protocol::transport::Protocol::V0,
+ Ok(1) => gix_protocol::transport::Protocol::V1,
+ Ok(2) => gix_protocol::transport::Protocol::V2,
+ Ok(other) => {
+ return Err(crate::config::key::GenericErrorWithValue::from_value(
+ self,
+ other.to_string().into(),
+ ))
+ }
+ Err(err) => {
+ return Err(
+ crate::config::key::GenericErrorWithValue::from_value(self, "unknown".into()).with_source(err),
+ )
+ }
+ })
+ }
+ }
+}
+
mod validate {
use crate::{bstr::BStr, config::tree::keys};
@@ -82,4 +119,17 @@ mod validate {
Ok(())
}
}
+
+ pub struct Version;
+ impl keys::Validate for Version {
+ fn validate(&self, value: &BStr) -> Result<(), Box<dyn std::error::Error + Send + Sync + 'static>> {
+ let value = gix_config::Integer::try_from(value)?
+ .to_decimal()
+ .ok_or_else(|| format!("integer {value} cannot be represented as integer"))?;
+ match value {
+ 0 | 1 | 2 => Ok(()),
+ _ => Err(format!("protocol version {value} is unknown").into()),
+ }
+ }
+ }
}