summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--Documentation/config.txt8
-rw-r--r--read-cache.c12
2 files changed, 20 insertions, 0 deletions
diff --git a/Documentation/config.txt b/Documentation/config.txt
index 1df1965457..bc7b216d43 100644
--- a/Documentation/config.txt
+++ b/Documentation/config.txt
@@ -329,6 +329,14 @@ advice.*::
show directions on how to proceed from the current state.
--
+core.checksumIndex::
+ Tell Git to validate the checksum at the end of the index
+ file to detect corruption. Defaults to `true`. Those who
+ work on a project with too many files may want to set this
+ variable to `false` to make it faster to load the index (in
+ exchange for reliability, but in general modern disks are
+ reliable enough for most people).
+
core.fileMode::
Tells Git if the executable bit of files in the working tree
is to be honored.
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);