pub struct ConfigSet { /* private fields */ }Expand description
A merged view across all configuration scopes.
Entries are stored in file-order within each scope; scopes are layered in priority order (system < global < local < worktree < command).
Implementations§
Source§impl ConfigSet
impl ConfigSet
Sourcepub fn entries(&self) -> &[ConfigEntry]
pub fn entries(&self) -> &[ConfigEntry]
All merged entries in load order (for listing keys such as alias.*).
Sourcepub fn merge(&mut self, file: &ConfigFile)
pub fn merge(&mut self, file: &ConfigFile)
Merge entries from a ConfigFile into this set.
Entries are appended; later values override earlier ones for single-value lookups.
Sourcepub fn add_command_override(&mut self, key: &str, value: &str) -> Result<()>
pub fn add_command_override(&mut self, key: &str, value: &str) -> Result<()>
Add a command-line override (-c key=value).
Sourcepub fn get_last_entry(&self, key: &str) -> Option<ConfigEntry>
pub fn get_last_entry(&self, key: &str) -> Option<ConfigEntry>
Last (highest-priority) ConfigEntry for a key, including origin metadata.
Bare boolean keys are returned with ConfigEntry::value set to None (same as get,
which maps them to "true" for string lookups).
Sourcepub fn get_all(&self, key: &str) -> Vec<String>
pub fn get_all(&self, key: &str) -> Vec<String>
Get all values for a key (multi-valued; in load order).
Sourcepub fn get_bool(&self, key: &str) -> Option<Result<bool, String>>
pub fn get_bool(&self, key: &str) -> Option<Result<bool, String>>
Get a boolean value, interpreting true/yes/on/1 as true and
false/no/off/0 as false.
Sourcepub fn quote_path_fully(&self) -> bool
pub fn quote_path_fully(&self) -> bool
Whether pathnames in human-readable output should fully C-quote non-ASCII bytes as octal.
Maps to Git’s quote_path_fully (core.quotepath, default true). When false, UTF-8 and
other high bytes are emitted literally; only ASCII specials are escaped. Also honors
core.quotePath as an alternate spelling.
Sourcepub fn effective_log_refs_config(&self, git_dir: &Path) -> LogRefsConfig
pub fn effective_log_refs_config(&self, git_dir: &Path) -> LogRefsConfig
Resolved core.logAllRefUpdates using this merged set (includes git -c / env), then Git’s
bare-repo default when the key is unset everywhere.
Sourcepub fn get_i64(&self, key: &str) -> Option<Result<i64, String>>
pub fn get_i64(&self, key: &str) -> Option<Result<i64, String>>
Get an integer value, supporting Git’s k/m/g suffixes.
Sourcepub fn get_regexp(&self, pattern: &str) -> Result<Vec<&ConfigEntry>, String>
pub fn get_regexp(&self, pattern: &str) -> Result<Vec<&ConfigEntry>, String>
Get all entries matching a key pattern (regex).
Used by git config --get-regexp. Returns an error if the pattern
is not a valid regex.
Sourcepub fn load_with_options(
git_dir: Option<&Path>,
opts: &LoadConfigOptions,
) -> Result<Self>
pub fn load_with_options( git_dir: Option<&Path>, opts: &LoadConfigOptions, ) -> Result<Self>
Load the standard configuration cascade with explicit include and scope control.
See LoadConfigOptions for GIT_CONFIG_PARAMETERS / -c include behaviour.
Sourcepub fn read_early_config(
git_dir: Option<&Path>,
key: &str,
) -> Result<Vec<String>>
pub fn read_early_config( git_dir: Option<&Path>, key: &str, ) -> Result<Vec<String>>
Read configuration the way Git’s read_early_config / do_git_config_sequence does:
system (unless disabled), global files in Git order, optional repository config /
config.worktree, then GIT_CONFIG_PARAMETERS.
When git_dir is None (no discovered repository, e.g. GIT_CEILING_DIRECTORIES), only
non-repo layers are read — matching Git when discovery returns no gitdir (t1309 ceiling #2).
Returns all values for key in load order (Git’s read_early_config callback runs once per
occurrence).
This matches upstream ordering for test-tool config read_early_config (t1309, t1305).
Sourcepub fn merge_file_with_includes(
&mut self,
file: &ConfigFile,
process_includes: bool,
ctx: &IncludeContext,
) -> Result<()>
pub fn merge_file_with_includes( &mut self, file: &ConfigFile, process_includes: bool, ctx: &IncludeContext, ) -> Result<()>
Merge a single config file, optionally expanding [include] / [includeIf].
Used by grit config -f and scoped reads; ConfigSet::load_with_options uses the same
internal routine for the standard cascade.
Sourcepub fn load_repo_local_only(git_dir: &Path) -> Result<Self>
pub fn load_repo_local_only(git_dir: &Path) -> Result<Self>
Load only the repository’s own config file (plus any [include] targets).
Unlike Self::load, this ignores system/global config and environment
overrides. Used for receive-side options (e.g. transfer.fsckObjects) so a
pusher’s global configuration cannot weaken the remote repository’s policy.
Sourcepub fn load_protected(include_system: bool) -> Result<Self>
pub fn load_protected(include_system: bool) -> Result<Self>
Load configuration the way Git loads protected config (e.g. uploadpack.packObjectsHook).
This matches Git’s read_protected_config: system (optional), global files only (no
repository or worktree config), then command-line overrides from GIT_CONFIG_COUNT /
GIT_CONFIG_PARAMETERS. It does not read $GIT_CONFIG (Git omits that for protected
config).
Global file order matches Git: XDG git/config first (when present), then ~/.gitconfig,
unless GIT_CONFIG_GLOBAL is set (single file). When both global files exist, both are
merged so later entries win for duplicate keys.