]> git.ipfire.org Git - thirdparty/git.git/commit
config: keep bailing on unreadable global files
authorDelilah Ashley Wu <delilahwu@microsoft.com>
Fri, 10 Oct 2025 01:14:09 +0000 (01:14 +0000)
committerJunio C Hamano <gitster@pobox.com>
Wed, 19 Nov 2025 15:14:27 +0000 (07:14 -0800)
commitf141ee7d7b74e337c5c52eabd54e01edbb471aef
tree3619ffcfcb888bce8e5d3356060459271454ce9a
parenteb3a952ca15b23953a709cfb0575cc82179c3960
config: keep bailing on unreadable global files

The expected behaviour for `git config list` is:
  A. Without `--global`, it should not bail on unreadable/non-existent
     global config files.

  B. With `--global`, it should bail when both `$HOME/.gitconfig` and
     `$XDG_CONFIG_HOME/git/config` are unreadable. It should not bail
     when one or more of them is readable.

The previous patch, config: read global scope via config_sequence,
introduced a regression in scenario B. When both global config files are
unreadable, running `git config list --global` would not fail. For
example, `GIT_CONFIG_GLOBAL=does-not-exist git config list --global`
exits with status code 0.

Assuming that `config_source->scope == CONFIG_SCOPE_GLOBAL` iff the
`--global` argument is specified, use this to determine whether to bail.
When reading only the global scope and both config files are unreadable,
then adjust the return code to be non-zero.

Note: When bailing, the exit code is not determined by sum of the return
codes of the underlying operations. Instead, the exit code is modified
via a single decrement. If this is undesirable, we can change it to sum
the return codes of the underlying operations instead.

Lastly, modify the tests to remove the known breakage/regression. The
tests for scenario B will now pass.

Helped-by: Derrick Stolee <stolee@gmail.com>
Signed-off-by: Delilah Ashley Wu <delilahwu@microsoft.com>
Reviewed-by: Johannes Schindelin <johannes.schindelin@gmx.de>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
config.c
t/t1300-config.sh