Skip to content

Commit eb1cd60

Browse files
avargitster
authored andcommitted
config tests: fix harmless but broken "rm -r" cleanup
The "test_when_finished" cleanup phase added in 4179b48 (config: allow overriding of global and system configuration, 2021-04-19) has never worked as intended, firstly the ".config/git" is a directory, so we'd need the "-r" flag, but more importantly the $HOME variable wasn't properly quoted. We'd thus end up trying to remove the "trash" part of "trash directory", which wouldn't fail with "-f", since "rm -f" won't fail on non-existing files. It's possible that this would have caused an actual failure if someone had a $HOME with a space character in it, such that our "rm -f" would fail to remove an existing directory, but in practice that probably never happened. Let's fix both the quoting issue, and the other issue cleanup issue in 4179b48, which is that we were attempting to clean up ~/.config/git, but weren't cleaing up ~/.gitconfig. Signed-off-by: Ævar Arnfjörð Bjarmason <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent 361fa32 commit eb1cd60

File tree

1 file changed

+3
-2
lines changed

1 file changed

+3
-2
lines changed

t/t1300-config.sh

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2083,12 +2083,13 @@ test_expect_success '--show-scope with --show-origin' '
20832083
'
20842084

20852085
test_expect_success 'override global and system config' '
2086-
test_when_finished rm -f "$HOME"/.config/git &&
2087-
2086+
test_when_finished rm -f \"\$HOME\"/.gitconfig &&
20882087
cat >"$HOME"/.gitconfig <<-EOF &&
20892088
[home]
20902089
config = true
20912090
EOF
2091+
2092+
test_when_finished rm -rf \"\$HOME\"/.config/git &&
20922093
mkdir -p "$HOME"/.config/git &&
20932094
cat >"$HOME"/.config/git/config <<-EOF &&
20942095
[xdg]

0 commit comments

Comments
 (0)