diff options
author | Jeff Hostetler <jeffhost@microsoft.com> | 2017-03-28 19:07:31 +0000 |
---|---|---|
committer | Junio C Hamano <gitster@pobox.com> | 2017-03-30 14:17:32 -0700 |
commit | 28962b19e8cdd1a583c488f8468abd72a3c5aaaa (patch) | |
tree | c15ba75afe180caf2ef113108a99e0c78e0a3a95 /read-cache.c | |
parent | e1104a5ee539408b81566066aaa6963cb87d5cd6 (diff) | |
download | git-jh/core-checksum-index.tar.gz |
read-cache: core.checksumindexjh/core-checksum-index
Teach git to skip verification of the SHA-1 checksum at the end of
the index file in verify_hdr() called from read_index() when the
core.checksumIndex configuration variable is set to false.
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.
On the Linux kernel repository, the effect is rather trivial.
The time to reading its index with 58k entries drops from 0.0284 sec
down to 0.0155 sec.
On my Windows source tree (450MB index), I'm seeing a savings of 0.6
seconds -- read_index() went from 1.2 to 0.6 seconds.
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 | 12 |
1 files changed, 12 insertions, 0 deletions
diff --git a/read-cache.c b/read-cache.c index e447751823..406fe76707 100644 --- a/read-cache.c +++ b/read-cache.c @@ -1376,12 +1376,24 @@ static int verify_hdr(struct cache_header *hdr, unsigned long size) git_SHA_CTX c; unsigned char sha1[20]; int hdr_version; + int do_checksum = 1; /* default to true for now */ if (hdr->hdr_signature != htonl(CACHE_SIGNATURE)) return error("bad signature"); 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); + + /* + * Since we run very early in command startup, git_config() + * may not have been called yet and the various "core_*" + * global variables haven't been set. So look it up + * explicitly. + */ + git_config_get_bool("core.checksumindex", &do_checksum); + if (!do_checksum) + return 0; + git_SHA1_Init(&c); git_SHA1_Update(&c, hdr, size - 20); git_SHA1_Final(sha1, &c); |