Repository navigation
Conversation
taekop
force-pushed
the
fix-git-cfg-get-global-levels
branch
from
October 20, 2026 10:27
7880008 to
7f33b0a
Compare
This branch has not been deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
git_cfg_get()read every row fromgert::git_config_global()that matched the key. That table includes the system, XDG and global levels, so a key set at two levels returned two values.git_sitrep()then printedDefault initial branch name: "master" and "main", anduse_git_config()warned when it tried to store the previous value.It now keeps only the rows from the highest-precedence level (programdata < system < xdg < global < local), which is what Git itself uses. Several values at a single level are still all returned, e.g.
credential.helper.I reproduced it on macOS by putting
init.defaultBranch = masterin$XDG_CONFIG_HOME/git/configandmainin~/.gitconfig, then callinggit_sitrep("git", "user"). It printed both values before and only"main"after.I compared
git_cfg_get()before and after across 10 config layouts (global only, XDG only, both, neither, differently cased keys, multi-valued keys at one level and at two levels, with and without a local value). Results differ only where a key is defined at more than one level.For the test I added a small
gert_config_global()wrapper so the config table can be mocked, and the test callsgit_sitrep(). It fails without the fix and passes with it. The full test suite passes with the same skips as main.Closes #2057