summaryrefslogtreecommitdiff
path: root/midx.c
diff options
context:
space:
mode:
authorTaylor Blau <me@ttaylorr.com>2021-06-23 18:39:15 (GMT)
committerJunio C Hamano <gitster@pobox.com>2021-06-29 03:36:17 (GMT)
commitf89ecf79888a48e0adf14d0e05c69ee09e853fd5 (patch)
tree82c2f643bee70555b091ef54e52dd6330c524b50 /midx.c
parentec1e28ef9c30468d2e76e41c88a1611e63047f61 (diff)
downloadgit-f89ecf79888a48e0adf14d0e05c69ee09e853fd5.zip
git-f89ecf79888a48e0adf14d0e05c69ee09e853fd5.tar.gz
git-f89ecf79888a48e0adf14d0e05c69ee09e853fd5.tar.bz2
midx: report checksum mismatches during 'verify'
'git multi-pack-index verify' inspects the data in an existing MIDX for correctness by checking that the recorded object offsets are correct, and so on. But it does not check that the file's trailing checksum matches the data that it records. So, if an on-disk corruption happened to occur in the final few bytes (and all other data was recorded correctly), we would: - get a clean result from 'git multi-pack-index verify', but - be unable to reuse the existing MIDX when writing a new one (since we now check for checksum mismatches before reusing a MIDX) Teach the 'verify' sub-command to recognize corruption in the checksum by calling midx_checksum_valid(). Suggested-by: Derrick Stolee <dstolee@microsoft.com> Signed-off-by: Taylor Blau <me@ttaylorr.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
Diffstat (limited to 'midx.c')
-rw-r--r--midx.c3
1 files changed, 3 insertions, 0 deletions
diff --git a/midx.c b/midx.c
index a12cbbf..9a35b02 100644
--- a/midx.c
+++ b/midx.c
@@ -1228,6 +1228,9 @@ int verify_midx_file(struct repository *r, const char *object_dir, unsigned flag
return result;
}
+ if (!midx_checksum_valid(m))
+ midx_report(_("incorrect checksum"));
+
if (flags & MIDX_PROGRESS)
progress = start_delayed_progress(_("Looking for referenced packfiles"),
m->num_packs);