From: SZEDER Gábor Date: Wed, 16 Oct 2013 00:48:57 +0000 (+0200) Subject: t3600: fix broken "choking git rm" test X-Git-Tag: v1.8.5-rc0~13^2 X-Git-Url: http://git.osdn.net/view?a=commitdiff_plain;h=056f34bbcdda2f7f85858ed8414afbed99686758;p=git-core%2Fgit.git 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 0693f9ddad (Make sure lockfiles are unlocked when dying on SIGPIPE, 2008-12-18), but since commit 4337b5856f (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 Reviewed-by: Jonathan Nieder Signed-off-by: Junio C Hamano --- diff --git a/t/t3600-rm.sh b/t/t3600-rm.sh index 9fd28bcf3..694165a64 100755 --- a/t/t3600-rm.sh +++ b/t/t3600-rm.sh @@ -240,18 +240,15 @@ test_expect_success 'refresh index before checking if it is up-to-date' ' test_expect_success 'choking "git rm" should not let it die with cruft' ' git reset -q --hard && + test_when_finished "rm -f .git/index.lock && git reset -q --hard" && i=0 && while test $i -lt 12000 do - echo "100644 $_z40 0 some-file-$i" + echo "100644 1234567890123456789012345678901234567890 0 some-file-$i" i=$(( $i + 1 )) done | git update-index --index-info && - git rm -n "some-file-*" | :; - test -f .git/index.lock - status=$? - rm -f .git/index.lock - git reset -q --hard - test "$status" != 0 + git rm -n "some-file-*" | : && + test_path_is_missing .git/index.lock ' test_expect_success 'rm removes subdirectories recursively' '