summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--builtin/fsck.c1
-rw-r--r--cache.h1
-rw-r--r--read-cache.c6
3 files changed, 8 insertions, 0 deletions
diff --git a/builtin/fsck.c b/builtin/fsck.c
index d18244ab54..81cc5ad78d 100644
--- a/builtin/fsck.c
+++ b/builtin/fsck.c
@@ -763,6 +763,7 @@ int cmd_fsck(int argc, const char **argv, const char *prefix)
if (keep_cache_objects) {
verify_index_checksum = 1;
+ verify_ce_order = 1;
read_cache();
for (i = 0; i < active_nr; i++) {
unsigned int mode;
diff --git a/cache.h b/cache.h
index 5cc116ba42..177f5ebcf2 100644
--- a/cache.h
+++ b/cache.h
@@ -720,6 +720,7 @@ extern int hold_locked_index(struct lock_file *, int);
extern void set_alternate_index_output(const char *);
extern int verify_index_checksum;
+extern int verify_ce_order;
/* Environment bits from configuration mechanism */
extern int trust_executable_bit;
diff --git a/read-cache.c b/read-cache.c
index 5e6d24d444..945a377447 100644
--- a/read-cache.c
+++ b/read-cache.c
@@ -1509,6 +1509,9 @@ struct ondisk_cache_entry_extended {
/* Allow fsck to force verification of the index checksum. */
int verify_index_checksum;
+/* Allow fsck to force verification of the cache entry order. */
+int verify_ce_order;
+
static int verify_hdr(struct cache_header *hdr, unsigned long size)
{
git_SHA_CTX c;
@@ -1666,6 +1669,9 @@ static void check_ce_order(struct index_state *istate)
{
unsigned int i;
+ if (!verify_ce_order)
+ return;
+
for (i = 1; i < istate->cache_nr; i++) {
struct cache_entry *ce = istate->cache[i - 1];
struct cache_entry *next_ce = istate->cache[i];