Skip to main content

Module config

Module config 

Source
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:

  1. System (/etc/gitconfig)
  2. Global (~/.gitconfig or $XDG_CONFIG_HOME/git/config)
  3. Local (.git/config)
  4. Worktree (.git/config.worktree)
  5. Command-line (-c key=value or GIT_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§

ConfigEntry
A single configuration entry with its origin metadata.
ConfigFile
A parsed configuration file that preserves the raw text for round-trip editing (set/unset/rename-section/remove-section).
ConfigSet
A merged view across all configuration scopes.
IncludeContext
Context for evaluating [includeIf] conditions (gitdir:, onbranch:).
LoadConfigOptions
Options controlling how ConfigSet::load_with_options merges files and includes.

Enums§

ConfigIncludeOrigin
Where a ConfigFile was loaded from for Git include semantics.
ConfigScope
The scope (origin) of a configuration value.
GitConfigIntStrictError
Why parse_git_config_int_strict failed (mirrors Git errno after git_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/g multiplier suffix, requiring the entire input (trimmed) to be consumed — same constraints as Git’s git_parse_signed used by git_config_int (so no and 1foo are rejected, unlike parse_i64).
parse_i64
Parse a Git integer value with optional k/m/g suffix.
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 — use parse_path_optional for that.
parse_path_optional
Parse a path value that may have an :(optional) prefix.
resolve_diff_context_lines
Read diff.context from a loaded ConfigSet with Git-compatible validation.
url_matches
Match a URL against a URL pattern from config.