You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
config: read from config sequence for global scope
The output of `git config list --global` should include both
`$HOME/.gitconfig` and `$XDG_CONFIG_HOME/git/config`, but it only reads
from the former.
We've assumed each config scope corresponds to a single config file
location. Because of this assumption, `git config list --global` reads
the global config by calling
`git_config_from_file_with_options(..., "~/.gitconfig", ...)`. This
function usage restricts us to a single source file. Since the global
scope includes more than one file, we should use another method to read
the global config.
The output of `git config list --show-scope --show-origin` correctly
includes both the home and XDG config files. So there's existing code
that respects both locations, namely the `do_git_config_sequence()`
function which reads from all scopes. Introduce flags that make it
possible to ignore all but the global scope (i.e. ignore system, local,
worktree, cmdline). Then, reuse this function for reading only the
global scope. This was the suggested solution in the original bug report
thread [1].
Note 1: The `ignore_global` flag is not set anywhere, so the
`if (!opts->ignore_global)` condition is always met. We can remove this
flag if desired.
Note 2: It's assumed that `config_source->scope == CONFIG_SCOPE_GLOBAL`
iff `--global` is specified. This comparison determines whether to call
`do_git_config_sequence()` for the global scope, or to keep calling
`git_config_from_file_with_options()` for other scopes.
Note 3: Keep populating `opts->source.file` in `builtin/config.c`
because it is used as the destination file for write operations. The
proposed changes could convolute the code because there is no single
source of truth for the config file locations in the global scope.
Add a comment to help clarify this. Please let me know if it's unclear.
[1]: https://lore.kernel.org/git/[email protected].
Reported-by: Jade Lovelace <[email protected]>
Suggested-by: Glen Choo <[email protected]>
Signed-off-by: Delilah Ashley Wu <[email protected]>
0 commit comments