diff options
author | Jeff Hostetler <jeffhost@microsoft.com> | 2017-04-14 20:32:21 +0000 |
---|---|---|
committer | Junio C Hamano <gitster@pobox.com> | 2017-04-15 00:58:36 -0700 |
commit | a33fc72fe911fdb8e284c94e08e8f1dafe4d3187 (patch) | |
tree | cda596575083fbfb2ad1c30ad449926931abe669 /read-cache.c | |
parent | Ninth batch for 2.13 (diff) | |
download | tgif-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 'read-cache.c')
-rw-r--r-- | read-cache.c | 7 |
1 files changed, 7 insertions, 0 deletions
diff --git a/read-cache.c b/read-cache.c index e447751823..008b335844 100644 --- a/read-cache.c +++ b/read-cache.c @@ -1371,6 +1371,9 @@ struct ondisk_cache_entry_extended { ondisk_cache_entry_extended_size(ce_namelen(ce)) : \ ondisk_cache_entry_size(ce_namelen(ce))) +/* Allow fsck to force verification of the index checksum. */ +int verify_index_checksum; + static int verify_hdr(struct cache_header *hdr, unsigned long size) { git_SHA_CTX c; @@ -1382,6 +1385,10 @@ static int verify_hdr(struct cache_header *hdr, unsigned long size) hdr_version = ntohl(hdr->hdr_version); if (hdr_version < INDEX_FORMAT_LB || INDEX_FORMAT_UB < hdr_version) return error("bad index version %d", hdr_version); + + if (!verify_index_checksum) + return 0; + git_SHA1_Init(&c); git_SHA1_Update(&c, hdr, size - 20); git_SHA1_Final(sha1, &c); |