@matheusbsbs / matheus-bagliano / commits / 55e1805dff
Fork 0

verify-pack: check integrity in a saner order.

Check internal integrity to report corrupt pack or idx, and then check cross-integrity between idx and pack. Signed-off-by: Linus Torvalds <torvalds@osdl.org> Signed-off-by: Junio C Hamano <junkio@cox.net>

Junio C Hamano committed Apr 27, 2006 at 15:42 UTC 55e1805dffeb5d2a8ccd717b2d07ca8887436a69
1 file changed +3 -3
pack-check.c
+3 -3
@@ -29,12 +29,12 @@ static int verify_packfile(struct packed_git *p)
29 pack_base = p->pack_base;
30 SHA1_Update(&ctx, pack_base, pack_size - 20);
31 SHA1_Final(sha1, &ctx);
32 - if (memcmp(sha1, index_base + index_size - 40, 20))
33 - return error("Packfile %s SHA1 mismatch with idx",
34 - p->pack_name);
32 if (memcmp(sha1, pack_base + pack_size - 20, 20))
33 return error("Packfile %s SHA1 mismatch with itself",
34 p->pack_name);
35 + if (memcmp(sha1, index_base + index_size - 40, 20))
36 + return error("Packfile %s SHA1 mismatch with idx",
37 + p->pack_name);
38
39 /* Make sure everything reachable from idx is valid. Since we
40 * have verified that nr_objects matches between idx and pack,