BUG: git config --global --get ITEM ignores ~/.config/git/config when ~/.gitconfig is present
- From
- Jade Lovelace <lists@jade.fyi>
- Date
- Feb 11, 2023, 00:39 UTC
- Message-ID
- <CAFA9we-QLQRzJdGMMCPatmfrk1oHeiUu9msMRXXk1MLE5HRxBQ@mail.gmail.com>
Dear maintainers,
I have found what I think is a bug or at least a documentation flaw in git-config: when both ~/.gitconfig and ~/.config/git/config exist, `git config` can retrieve items set in the latter, but not with the `--global` flag set. For context, I use ~/.gitconfig as a non-checked-in machine-specific config, and ~/.config/git/config as my checked-in all-machines configuration file.
The documentation states:
> When reading, the values are read from the system, global and repository local configuration files by default, and options --system, --global, --local, --worktree and --file can be used to tell the command to read from only that location (see the section called “FILES”).
Show 5 quoted lines
> FILES > $XDG_CONFIG_HOME/git/config, ~/.gitconfig > User-specific configuration files. When the XDG_CONFIG_HOME environment variable is not set or empty, $HOME/.config/ is used as $XDG_CONFIG_HOME. > > These are also called "global" configuration files. If both files exist, both files are read in the order given above.
Based on this documentation, I would expect `--global` to consider both global configuration files, but it does not.
Reproduction:
Set some setting in ~/.config/git/config, say: [pull] ff = only
Ensure that ~/.gitconfig exists.
Then:
» git config --global --get user.name » git config --show-scope --show-origin --get user.name global file:/home/jade/.config/git/config Jade Lovelace
» git --version git version 2.39.1
Regards, Jade