diff options
Diffstat (limited to 'vendor/gix/src/config/tree')
-rw-r--r-- | vendor/gix/src/config/tree/mod.rs | 9 | ||||
-rw-r--r-- | vendor/gix/src/config/tree/sections/clone.rs | 4 | ||||
-rw-r--r-- | vendor/gix/src/config/tree/sections/gitoxide.rs | 48 | ||||
-rw-r--r-- | vendor/gix/src/config/tree/sections/index.rs | 62 | ||||
-rw-r--r-- | vendor/gix/src/config/tree/sections/mod.rs | 5 |
5 files changed, 119 insertions, 9 deletions
diff --git a/vendor/gix/src/config/tree/mod.rs b/vendor/gix/src/config/tree/mod.rs index fd769f3ed..b378b8c49 100644 --- a/vendor/gix/src/config/tree/mod.rs +++ b/vendor/gix/src/config/tree/mod.rs @@ -38,6 +38,8 @@ pub(crate) mod root { pub const GITOXIDE: sections::Gitoxide = sections::Gitoxide; /// The `http` section. pub const HTTP: sections::Http = sections::Http; + /// The `index` section. + pub const INDEX: sections::Index = sections::Index; /// The `init` section. pub const INIT: sections::Init = sections::Init; /// The `pack` section. @@ -69,6 +71,7 @@ pub(crate) mod root { &Self::EXTENSIONS, &Self::GITOXIDE, &Self::HTTP, + &Self::INDEX, &Self::INIT, &Self::PACK, &Self::PROTOCOL, @@ -84,9 +87,9 @@ pub(crate) mod root { mod sections; pub use sections::{ - branch, checkout, core, credential, diff, extensions, gitoxide, http, protocol, remote, ssh, Author, Branch, - Checkout, Clone, Committer, Core, Credential, Diff, Extensions, Gitoxide, Http, Init, Pack, Protocol, Remote, Safe, - Ssh, Url, User, + branch, checkout, core, credential, diff, extensions, gitoxide, http, index, protocol, remote, ssh, Author, Branch, + Checkout, Clone, Committer, Core, Credential, Diff, Extensions, Gitoxide, Http, Index, Init, Pack, Protocol, + Remote, Safe, Ssh, Url, User, }; /// Generic value implementations for static instantiation. diff --git a/vendor/gix/src/config/tree/sections/clone.rs b/vendor/gix/src/config/tree/sections/clone.rs index 616185a0b..6cb274e7d 100644 --- a/vendor/gix/src/config/tree/sections/clone.rs +++ b/vendor/gix/src/config/tree/sections/clone.rs @@ -7,6 +7,8 @@ impl Clone { /// The `clone.defaultRemoteName` key. pub const DEFAULT_REMOTE_NAME: keys::RemoteName = keys::RemoteName::new_remote_name("defaultRemoteName", &config::Tree::CLONE); + /// The `clone.rejectShallow` key. + pub const REJECT_SHALLOW: keys::Boolean = keys::Boolean::new_boolean("rejectShallow", &config::Tree::CLONE); } impl Section for Clone { @@ -15,6 +17,6 @@ impl Section for Clone { } fn keys(&self) -> &[&dyn Key] { - &[&Self::DEFAULT_REMOTE_NAME] + &[&Self::DEFAULT_REMOTE_NAME, &Self::REJECT_SHALLOW] } } diff --git a/vendor/gix/src/config/tree/sections/gitoxide.rs b/vendor/gix/src/config/tree/sections/gitoxide.rs index 8c3defd0b..7d60f1287 100644 --- a/vendor/gix/src/config/tree/sections/gitoxide.rs +++ b/vendor/gix/src/config/tree/sections/gitoxide.rs @@ -1,10 +1,15 @@ -use crate::config::tree::{keys, Gitoxide, Key, Section}; +use crate::{ + config, + config::tree::{keys, Gitoxide, Key, Section}, +}; impl Gitoxide { /// The `gitoxide.allow` section. pub const ALLOW: Allow = Allow; /// The `gitoxide.author` section. pub const AUTHOR: Author = Author; + /// The `gitoxide.core` section. + pub const CORE: Core = Core; /// The `gitoxide.commit` section. pub const COMMIT: Commit = Commit; /// The `gitoxide.committer` section. @@ -39,6 +44,7 @@ impl Section for Gitoxide { &[ &Self::ALLOW, &Self::AUTHOR, + &Self::CORE, &Self::COMMIT, &Self::COMMITTER, &Self::HTTP, @@ -56,6 +62,41 @@ mod subsections { Tree, }; + /// The `Core` sub-section. + #[derive(Copy, Clone, Default)] + pub struct Core; + + impl Core { + /// 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."); + + /// The `gitoxide.core.useStdev` key. + pub const USE_STDEV: keys::Boolean = keys::Boolean::new_boolean("useStdev", &Gitoxide::CORE) + .with_note("A runtime version of the USE_STDEV build flag."); + + /// The `gitoxide.core.shallowFile` key. + pub const SHALLOW_FILE: keys::Path = keys::Path::new_path("shallowFile", &Gitoxide::CORE) + .with_environment_override("GIT_SHALLOW_FILE") + .with_deviation( + "relative file paths will always be made relative to the git-common-dir, whereas `git` keeps them as is.", + ); + } + + impl Section for Core { + fn name(&self) -> &str { + "core" + } + + fn keys(&self) -> &[&dyn Key] { + &[&Self::USE_NSEC, &Self::USE_STDEV, &Self::SHALLOW_FILE] + } + + fn parent(&self) -> Option<&dyn Section> { + Some(&Tree::GITOXIDE) + } + } + /// The `Http` sub-section. #[derive(Copy, Clone, Default)] pub struct Http; @@ -341,6 +382,7 @@ mod subsections { } } } +pub use subsections::{Allow, Author, Commit, Committer, Core, Http, Https, Objects, Ssh, User}; pub mod validate { use std::error::Error; @@ -357,7 +399,3 @@ pub mod validate { } } } - -pub use subsections::{Allow, Author, Commit, Committer, Http, Https, Objects, Ssh, User}; - -use crate::config; diff --git a/vendor/gix/src/config/tree/sections/index.rs b/vendor/gix/src/config/tree/sections/index.rs new file mode 100644 index 000000000..d03322247 --- /dev/null +++ b/vendor/gix/src/config/tree/sections/index.rs @@ -0,0 +1,62 @@ +use crate::{ + config, + config::tree::{keys, Index, Key, Section}, +}; + +impl Index { + /// The `index.threads` key. + pub const THREADS: IndexThreads = + IndexThreads::new_with_validate("threads", &config::Tree::INDEX, validate::IndexThreads); +} + +/// The `index.threads` key. +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; + + 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. + pub fn try_into_index_threads( + &'static self, + value: Cow<'_, BStr>, + ) -> Result<usize, config::key::GenericErrorWithValue> { + gix_config::Integer::try_from(value.as_ref()) + .ok() + .and_then(|i| i.to_decimal().and_then(|i| i.try_into().ok())) + .or_else(|| { + gix_config::Boolean::try_from(value.as_ref()) + .ok() + .map(|b| if b.0 { 0 } else { 1 }) + }) + .ok_or_else(|| GenericErrorWithValue::from_value(self, value.into_owned())) + } + } +} + +impl Section for Index { + fn name(&self) -> &str { + "index" + } + + fn keys(&self) -> &[&dyn Key] { + &[&Self::THREADS] + } +} + +mod validate { + use crate::{bstr::BStr, config::tree::keys}; + + pub struct IndexThreads; + impl keys::Validate for IndexThreads { + fn validate(&self, value: &BStr) -> Result<(), Box<dyn std::error::Error + Send + Sync + 'static>> { + super::Index::THREADS.try_into_index_threads(value.into())?; + Ok(()) + } + } +} diff --git a/vendor/gix/src/config/tree/sections/mod.rs b/vendor/gix/src/config/tree/sections/mod.rs index fb9b50786..9f0a50c93 100644 --- a/vendor/gix/src/config/tree/sections/mod.rs +++ b/vendor/gix/src/config/tree/sections/mod.rs @@ -55,6 +55,11 @@ pub mod gitoxide; pub struct Http; pub mod http; +/// The `index` top-level section. +#[derive(Copy, Clone, Default)] +pub struct Index; +pub mod index; + /// The `init` top-level section. #[derive(Copy, Clone, Default)] pub struct Init; |