Re: [PATCH] make verify-pack a bit more useful with bad packs
- From
Junio C Hamano <gitster@pobox.com>
- Date
- Jun 2, 2008, 06:27 UTC
- Message-ID
- <7vskvw8i77.fsf@gitster.siamese.dyndns.org>
- In-Reply-To
- <alpine.LFD.1.10.0805291716470.23581@xanadu.home>
Nicolas Pitre <nico@cam.org> writes:
Show 22 quoted lines
> 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.