Skip to content

Commit 056f34b

Browse files
szedergitster
authored andcommitted
t3600: fix broken "choking git rm" test
The test 'choking "git rm" should not let it die with cruft' is supposed to check 'git rm's behavior when interrupted by provoking a SIGPIPE while 'git rm' is busily deleting files from a specially crafted index. This test is silently broken for the following reasons: - The test crafts a special index by feeding a large number of index entries with null shas to 'git update-index --index-info'. It was OK back then when this test was introduced in commit 0693f9d (Make sure lockfiles are unlocked when dying on SIGPIPE, 2008-12-18), but since commit 4337b58 (do not write null sha1s to on-disk index, 2012-07-28) null shas are not allowed in the on-disk index causing 'git update-index' to error out. - The barfing 'git update-index --index-info' should fail the test, but it remains unnoticed because of the severely broken && chain: the test's result depends solely on whether there is a stale lock file left behind, but after 'git update-index' errors out 'git rm' won't be executed at all. To fix this test feed only non-null shas to 'git update-index' and restore the && chain (partly by adding a missing && and by using the test_when_finished helper instead of manual cleanup). Signed-off-by: SZEDER Gábor <[email protected]> Reviewed-by: Jonathan Nieder <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent 4337b58 commit 056f34b

File tree

1 file changed

+4
-7
lines changed

1 file changed

+4
-7
lines changed

t/t3600-rm.sh

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -240,18 +240,15 @@ test_expect_success 'refresh index before checking if it is up-to-date' '
240240

241241
test_expect_success 'choking "git rm" should not let it die with cruft' '
242242
git reset -q --hard &&
243+
test_when_finished "rm -f .git/index.lock && git reset -q --hard" &&
243244
i=0 &&
244245
while test $i -lt 12000
245246
do
246-
echo "100644 $_z40 0 some-file-$i"
247+
echo "100644 1234567890123456789012345678901234567890 0 some-file-$i"
247248
i=$(( $i + 1 ))
248249
done | git update-index --index-info &&
249-
git rm -n "some-file-*" | :;
250-
test -f .git/index.lock
251-
status=$?
252-
rm -f .git/index.lock
253-
git reset -q --hard
254-
test "$status" != 0
250+
git rm -n "some-file-*" | : &&
251+
test_path_is_missing .git/index.lock
255252
'
256253

257254
test_expect_success 'rm removes subdirectories recursively' '

0 commit comments

Comments
 (0)