pub struct ConfigSnapshot { /* private fields */ }Expand description
What:
The parsed listing of one Git configuration read.
Why:
It is read once per commit with the caller’s global options, and reused by the consumers that would
otherwise each start git config.
In TS you’d write (pseudocode):
type ConfigSnapshot = { entries: ConfigEntry[]; readWithoutGlobalOptions: boolean };Implementations§
Source§impl ConfigSnapshot
impl ConfigSnapshot
Sourcepub fn parse(listing: &[u8], without_global_options: bool) -> Option<Self>
pub fn parse(listing: &[u8], without_global_options: bool) -> Option<Self>
What:
Parse the bytes of git config --list -z --show-scope.
Why:
The listing is scope NUL key [LF value] NUL repeated; a listing in any other shape is refused whole,
so a half-understood configuration is never used.
In TS you’d write (pseudocode):
parseConfigList(bytes, { withoutGlobalOptions });Sourcepub fn entries(&self) -> &[ConfigEntry]
pub fn entries(&self) -> &[ConfigEntry]
What: The entries in listing order. Why: Consumers that scan for a family of keys (hook definitions) read them directly.
In TS you’d write (pseudocode):
snapshot.entriesSourcepub fn without_global_options(&self) -> bool
pub fn without_global_options(&self) -> bool
What:
Whether the read carried no global options, so a consumer that runs Git without them may reuse it.
Why:
A -c, -C or --git-dir in front of the read changes what Git lists, and a consumer that ignores the
caller’s options must not see their effect.
In TS you’d write (pseudocode):
snapshot.withoutGlobalOptionsSourcepub fn path_value(&self, key: &str) -> Lookup<String>
pub fn path_value(&self, key: &str) -> Lookup<String>
What:
git config --type=path --get <key> for values Git returns unchanged.
Why:
core.hooksPath is read this way.
In TS you’d write (pseudocode):
snapshot.pathValue('core.hookspath');Sourcepub fn bool_value(&self, key: &str) -> Lookup<bool>
pub fn bool_value(&self, key: &str) -> Lookup<bool>
What:
git config --type=bool --get <key>.
Why:
The hook switches are read this way.
In TS you’d write (pseudocode):
snapshot.boolValue('hook.pre-commit.enabled');Sourcepub fn maintenance_records(&self) -> Option<BTreeMap<String, String>>
pub fn maintenance_records(&self) -> Option<BTreeMap<String, String>>
What:
The maintenance keys as git config --type=bool-or-int --null --get-regexp prints them: each set key
with the text of its last value.
Why:
The maintenance decision parses that listing; None when any maintenance entry is not modelled.
In TS you’d write (pseudocode):
snapshot.maintenanceRecords();Sourcepub fn defines_named_hook(&self) -> bool
pub fn defines_named_hook(&self) -> bool
What:
Whether any entry defines a hook by name: a hook.<name>.event or hook.<name>.command key.
Why:
Git runs such a hook for its event whatever the hooks directory holds, so a repository with one keeps
every dispatcher entry.
In TS you’d write (pseudocode):
entries.some((entry) => /^hook\..*\.(event|command)$/.test(entry.key));Sourcepub fn proves_files_ref_storage(&self) -> bool
pub fn proves_files_ref_storage(&self) -> bool
What:
Whether the ref storage is proven to be the files backend.
Why:
git rev-parse --show-ref-format prints reftable only when extensions.refStorage is set, so a
listing without that key, read without global options, proves files; any listing that names the key
(in any scope, from any file) is left to Git, which also applies the repository-format rules.
In TS you’d write (pseudocode):
snapshot.withoutGlobalOptions && !snapshot.entries.some((entry) => entry.key === 'extensions.refstorage');Trait Implementations§
Source§impl Clone for ConfigSnapshot
impl Clone for ConfigSnapshot
Source§impl Debug for ConfigSnapshot
impl Debug for ConfigSnapshot
impl Eq for ConfigSnapshot
Source§impl PartialEq for ConfigSnapshot
impl PartialEq for ConfigSnapshot
impl StructuralPartialEq for ConfigSnapshot
Auto Trait Implementations§
impl Freeze for ConfigSnapshot
impl RefUnwindSafe for ConfigSnapshot
impl Send for ConfigSnapshot
impl Sync for ConfigSnapshot
impl Unpin for ConfigSnapshot
impl UnsafeUnpin for ConfigSnapshot
impl UnwindSafe for ConfigSnapshot
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
key and return true if they are equal.Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
Source§fn in_current_span(self) -> Instrumented<Self> ⓘ
fn in_current_span(self) -> Instrumented<Self> ⓘ
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more