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 the home
(`$HOME/.gitconfig`) and XDG (`$XDG_CONFIG_HOME/git/config`) configs,
but it only reads from the former.
We assumed each config scope corresponds to a single config file. Under
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 config file. Because the
global scope includes two files, we should read the configs via another
method.
The output of `git config list --show-scope --show-origin` (without
`--global`) 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 to make it possible to ignore all but the global scope
(i.e. ignore system, local, worktree, and cmdline). Then, reuse the
function to read only the global scope when `--global` is specified.
This was the suggested solution in the bug report:
https://lore.kernel.org/git/[email protected].
Then, modify the tests to check that `git config list --global` includes
both home and XDG configs.
This change introduces a regression: if both global config files are
unreadable, then `git config list --global` should exit non-zero. This
is no longer the case, so mark the corresponding test as a "TODO known
breakage" and address the issue in the next patch.
Implementation notes:
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.
2. I've 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.
3. Keep populating `opts->source.file` in `builtin/config.c` because
it is used as the destination confile 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.
Reported-by: Jade Lovelace <[email protected]>
Helped-by: Derrick Stolee <[email protected]>
Suggested-by: Glen Choo <[email protected]>
Signed-off-by: Delilah Ashley Wu <[email protected]>
0 commit comments