summaryrefslogtreecommitdiff
path: root/t
diff options
context:
space:
mode:
authorLibravatar Jeff Hostetler <jeffhost@microsoft.com>2017-04-14 20:32:21 +0000
committerLibravatar Junio C Hamano <gitster@pobox.com>2017-04-15 00:58:36 -0700
commita33fc72fe911fdb8e284c94e08e8f1dafe4d3187 (patch)
treecda596575083fbfb2ad1c30ad449926931abe669 /t
parentNinth batch for 2.13 (diff)
downloadtgif-a33fc72fe911fdb8e284c94e08e8f1dafe4d3187.tar.xz
read-cache: force_verify_index_checksum
Teach git to skip verification of the SHA1-1 checksum at the end of the index file in verify_hdr() which is called from read_index() unless the "force_verify_index_checksum" global variable is set. Teach fsck to force this verification. The checksum verification is for detecting disk corruption, and for small projects, the time it takes to compute SHA-1 is not that significant, but for gigantic repositories this calculation adds significant time to every command. These effect can be seen using t/perf/p0002-read-cache.sh: Test HEAD~1 HEAD -------------------------------------------------------------------------------------- 0002.1: read_cache/discard_cache 1000 times 0.66(0.44+0.20) 0.30(0.27+0.02) -54.5% Signed-off-by: Jeff Hostetler <jeffhost@microsoft.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
Diffstat (limited to 't')
-rwxr-xr-xt/t1450-fsck.sh13
1 files changed, 13 insertions, 0 deletions
diff --git a/t/t1450-fsck.sh b/t/t1450-fsck.sh
index 33a51c9a67..677e15a7a4 100755
--- a/t/t1450-fsck.sh
+++ b/t/t1450-fsck.sh
@@ -689,4 +689,17 @@ test_expect_success 'bogus head does not fallback to all heads' '
! grep $blob out
'
+test_expect_success 'detect corrupt index file in fsck' '
+ cp .git/index .git/index.backup &&
+ test_when_finished "mv .git/index.backup .git/index" &&
+ echo zzzzzzzz >zzzzzzzz &&
+ git add zzzzzzzz &&
+ sed -e "s/zzzzzzzz/yyyyyyyy/" .git/index >.git/index.yyy &&
+ mv .git/index.yyy .git/index &&
+ # Confirm that fsck detects invalid checksum
+ test_must_fail git fsck --cache &&
+ # Confirm that status no longer complains about invalid checksum
+ git status
+'
+
test_done