Skip to content

Commit

Permalink
t1300: fix unset of GIT_CONFIG_NOSYSTEM leaking into subsequent tests
Browse files Browse the repository at this point in the history
In order to test whether the new GIT_CONFIG_SYSTEM environment variable
behaves as expected, we unset GIT_CONFIG_NOSYSTEM in one of our tests in
t1300. But because tests are not executed in a subshell, this unset
leaks into all subsequent tests and may thus cause them to fail in some
environments. These failures are easily reproducable with `make
prefix=/root test`.

Fix the issue by not using `sane_unset GIT_CONFIG_NOSYSTEM`, but instead
just manually add it to the environment of the two command invocations
which need it.

Reported-by: SZEDER Gábor <szeder.dev@gmail.com>
Signed-off-by: Patrick Steinhardt <ps@pks.im>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
  • Loading branch information
pks-t authored and gitster committed Apr 27, 2021
1 parent 4179b48 commit 482d549
Showing 1 changed file with 3 additions and 4 deletions.
7 changes: 3 additions & 4 deletions t/t1300-config.sh
Original file line number Diff line number Diff line change
Expand Up @@ -2092,21 +2092,20 @@ test_expect_success 'override global and system config' '
git config --show-scope --list >output &&
test_cmp expect output &&
sane_unset GIT_CONFIG_NOSYSTEM &&
cat >expect <<-EOF &&
system system.config=true
global global.config=true
local local.config=true
EOF
GIT_CONFIG_SYSTEM=custom-system-config GIT_CONFIG_GLOBAL=custom-global-config \
GIT_CONFIG_NOSYSTEM=false GIT_CONFIG_SYSTEM=custom-system-config GIT_CONFIG_GLOBAL=custom-global-config \
git config --show-scope --list >output &&
test_cmp expect output &&
cat >expect <<-EOF &&
local local.config=true
EOF
GIT_CONFIG_SYSTEM=/dev/null GIT_CONFIG_GLOBAL=/dev/null git config --show-scope --list >output &&
GIT_CONFIG_NOSYSTEM=false GIT_CONFIG_SYSTEM=/dev/null GIT_CONFIG_GLOBAL=/dev/null \
git config --show-scope --list >output &&
test_cmp expect output
'

Expand Down

0 comments on commit 482d549

Please sign in to comment.