Expand description
Git-compatible configuration file parser and accessor.
Supports the standard Git config file format:
[section]
key = value
[section "subsection"]
key = value§Multi-file layering
Git reads configuration from several files in priority order:
- System (
/etc/gitconfig) - Global (
~/.gitconfigor$XDG_CONFIG_HOME/git/config) - Local (
.git/config) - Worktree (
.git/config.worktree) - Command-line (
-c key=valueorGIT_CONFIG_*)
ConfigSet merges all layers; last-wins for single-valued keys.
§Include directives
[include] path = <path> and [includeIf "<condition>"] path = <path>
are supported. Conditions: gitdir:, gitdir/i:, onbranch:.
Structs§
- Config
Entry - A single configuration entry with its origin metadata.
- Config
File - A parsed configuration file that preserves the raw text for round-trip editing (set/unset/rename-section/remove-section).
- Config
Set - A merged view across all configuration scopes.
- Include
Context - Context for evaluating
[includeIf]conditions (gitdir:,onbranch:). - Load
Config Options - Options controlling how
ConfigSet::load_with_optionsmerges files and includes.
Enums§
- Config
Include Origin - Where a
ConfigFilewas loaded from for Git include semantics. - Config
Scope - The scope (origin) of a configuration value.
- GitConfig
IntStrict Error - Why
parse_git_config_int_strictfailed (mirrors Giterrnoaftergit_parse_signed).
Functions§
- canonical_
key - Normalise a config key to canonical form.
- get_
urlmatch_ all_ in_ section - Get all matching variables in a section for a given URL.
- get_
urlmatch_ entries - Get the best URL match for a specific key.
- global_
config_ paths_ pub - Return candidate paths for the global config file, in priority order. Public accessor for the ordered list of global config file paths.
- parse_
bool - Parse a Git boolean value.
- parse_
color - Parse a Git color value and return the ANSI escape sequence.
- parse_
git_ config_ int_ strict - Parse a signed decimal integer with optional
k/m/gmultiplier suffix, requiring the entire input (trimmed) to be consumed — same constraints as Git’sgit_parse_signedused bygit_config_int(sonoand1fooare rejected, unlikeparse_i64). - parse_
i64 - Parse a Git integer value with optional
k/m/gsuffix. - parse_
path - Parse a Git path value (expand
~/to home directory). Parse a path value. Returns the resolved path string. Does NOT handle :(optional) prefix — useparse_path_optionalfor that. - parse_
path_ optional - Parse a path value that may have an
:(optional)prefix. - resolve_
diff_ context_ lines - Read
diff.contextfrom a loadedConfigSetwith Git-compatible validation. - url_
matches - Match a URL against a URL pattern from config.