Re: [PATCH] make verify-pack a bit more useful with bad packs
From: Junio C Hamano <hidden>
Date: 2016-06-15 22:44:40
Nicolas Pitre [off-list ref] writes:
When a pack gets corrupted, its SHA1 checksum will fail. However, this
is more useful to let the test go on in order to find the actual
problem location than only complain about the SHA1 mismatch and
bail out.
...
/* Verify SHA1 sum of the index file */
SHA1_Init(&ctx);
SHA1_Update(&ctx, index_base, (unsigned int)(index_size - 20));
SHA1_Final(sha1, &ctx);
if (hashcmp(sha1, index_base + index_size - 20))
- ret = error("Packfile index for %s SHA1 mismatch",
+ err = error("Packfile index for %s SHA1 mismatch",
p->pack_name);
- if (!ret) {
- /* Verify pack file */
- struct pack_window *w_curs = NULL;
- ret = verify_packfile(p, &w_curs);
- unuse_pack(&w_curs);
- }
+ /* Verify pack file */
+ err = verify_packfile(p, &w_curs);This overwrites the index SHA-1 mismatch you detected earlier. An obvious fix-up would be to: err |= verify_packfile(p, &w_curs); Will be in 1.5.6-rc1.