Skip to main content

Module config

Module config 

Source
Expand description

Reading configuration — and reading it the way git itself does.

Everything this project can be tuned with is a git config key, so the honest implementation of that promise is to let git do the parsing. git config --type=bool implements git-config(1) by definition: on, yes, 1, an empty value, and every capitalisation of each. A hand-rolled matches!(v, "true" | "1" | "yes") is our own dialect wearing git’s clothes, and it had already drifted — git config amont.fix on looked like it worked and did not.

The exit code carries the part that matters most:

exitmeans
0the key is set, and stdout is git’s normalised value
1the key is not set anywhere git looked
128the key is set to something git refuses to parse, and said so on stderr

Collapsing 1 and 128 into “no” is the bug this module exists to prevent: a limit you believe you raised and did not is exactly the silent-config failure that hook.skip announcements were introduced for. So a bad value falls back to the shipped default and says so, once per key per run.

Enums§

Scope
Where a key’s value came from, for the commands whose job is reading configuration back.
Value
What a key said. Three answers, because “unset” is a state this project makes decisions with — amont.commit.gitmoji has four meanings and one of them is absence.

Functions§

boolean
boolean_or
complain
Say once, per key, that a configured value could not be used.
enumerated
One of a fixed set of words, compared case-insensitively.
enumerated_or
integer
An integer, in git’s own spelling — which includes the k/m/g suffixes git accepts, since --type=int expands them before we see them.
integer_or
An integer, clamped to what the setting can actually mean.
is_present
Is key among the names present returned? Case-insensitive, because git config key names are.
present
Which keys under prefix are set at all — one git call for the whole family.
scope_of
git config --show-origin --get <key> → which file it came from.