t1300: fix unset of GIT_CONFIG_NOSYSTEM leaking into subsequent tests

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>

Patrick Steinhardt committed Apr 23, 2021 at 07:47 UTC 482d5499067b2a1fc8d1ebfb5160022dc23ab136
1 file changed +3 -4
t/t1300-config.sh
+3 -4
@@ -2092,21 +2092,20 @@ test_expect_success 'override global and system config' '
2092 git config --show-scope --list >output &&
2093 test_cmp expect output &&
2094
2095 - sane_unset GIT_CONFIG_NOSYSTEM &&
2096 -
2095 cat >expect <<-EOF &&
2096 system system.config=true
2097 global global.config=true
2098 local local.config=true
2099 EOF
2102 - GIT_CONFIG_SYSTEM=custom-system-config GIT_CONFIG_GLOBAL=custom-global-config \
2100 + GIT_CONFIG_NOSYSTEM=false GIT_CONFIG_SYSTEM=custom-system-config GIT_CONFIG_GLOBAL=custom-global-config \
2101 git config --show-scope --list >output &&
2102 test_cmp expect output &&
2103
2104 cat >expect <<-EOF &&
2105 local local.config=true
2106 EOF
2109 - GIT_CONFIG_SYSTEM=/dev/null GIT_CONFIG_GLOBAL=/dev/null git config --show-scope --list >output &&
2107 + GIT_CONFIG_NOSYSTEM=false GIT_CONFIG_SYSTEM=/dev/null GIT_CONFIG_GLOBAL=/dev/null \
2108 + git config --show-scope --list >output &&
2109 test_cmp expect output
2110 '
2111