Browse Source

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>
maint
Junio C Hamano 19 years ago
parent
commit
55e1805dff
  1. 6
      pack-check.c

6
pack-check.c

@ -29,12 +29,12 @@ static int verify_packfile(struct packed_git *p)
pack_base = p->pack_base; pack_base = p->pack_base;
SHA1_Update(&ctx, pack_base, pack_size - 20); SHA1_Update(&ctx, pack_base, pack_size - 20);
SHA1_Final(sha1, &ctx); SHA1_Final(sha1, &ctx);
if (memcmp(sha1, index_base + index_size - 40, 20))
return error("Packfile %s SHA1 mismatch with idx",
p->pack_name);
if (memcmp(sha1, pack_base + pack_size - 20, 20)) if (memcmp(sha1, pack_base + pack_size - 20, 20))
return error("Packfile %s SHA1 mismatch with itself", return error("Packfile %s SHA1 mismatch with itself",
p->pack_name); p->pack_name);
if (memcmp(sha1, index_base + index_size - 40, 20))
return error("Packfile %s SHA1 mismatch with idx",
p->pack_name);


/* Make sure everything reachable from idx is valid. Since we /* Make sure everything reachable from idx is valid. Since we
* have verified that nr_objects matches between idx and pack, * have verified that nr_objects matches between idx and pack,

Loading…
Cancel
Save