From: Jeff Hostetler <jeffhost@xxxxxxxxxxxxx> Teach git to skip verification of the index SHA in read_index(). This is a performance optimization. The index file SHA verification can be considered an ancient relic from the early days of git and only useful for detecting disk corruption. For small repositories, this SHA calculation is not that significant, but for gigantic repositories this calculation adds significant time to every command. I added a global "skip_verify_index" variable to control this and allow it to be tested. I did not create a config setting for this because of chicken-n-egg problems with the loading the config and the index. Signed-off-by: Jeff Hostetler <jeffhost@xxxxxxxxxxxxx> --- cache.h | 5 +++++ read-cache.c | 6 ++++++ 2 files changed, 11 insertions(+) diff --git a/cache.h b/cache.h index 80b6372..4e9182f 100644 --- a/cache.h +++ b/cache.h @@ -740,6 +740,11 @@ extern int protect_ntfs; extern int git_db_env, git_index_env, git_graft_env, git_common_dir_env; /* + * When set, skip verification of the index SHA in read_index(). + */ +extern int skip_verify_index; + +/* * Include broken refs in all ref iterations, which will * generally choke dangerous operations rather than letting * them silently proceed without taking the broken ref into diff --git a/read-cache.c b/read-cache.c index 9054369..1ca69c3 100644 --- a/read-cache.c +++ b/read-cache.c @@ -46,6 +46,8 @@ struct index_state the_index; static const char *alternate_index_output; +int skip_verify_index = 1; + static void set_index_entry(struct index_state *istate, int nr, struct cache_entry *ce) { istate->cache[nr] = ce; @@ -1382,6 +1384,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 (skip_verify_index) + return 0; + git_SHA1_Init(&c); git_SHA1_Update(&c, hdr, size - 20); git_SHA1_Final(sha1, &c); -- 2.7.4