verify_packfile(): check as many object as possible in a pack

verify_packfile() checks for whole pack integerity first, then each object individually. Once we get past whole pack check, we can identify all objects in the pack. If there's an error with one object, we should continue to check the next objects to salvage as many objects as possible instead of stopping the process. Signed-off-by: Nguyễn Thái Ngọc Duy <pclouds@gmail.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>

Nguyễn Thái Ngọc Duy committed Nov 7, 2011 at 09:59 UTC 473935188cc9b0363b30553f23d816231a66cb44
1 file changed +2 -7
pack-check.c
+2 -7
@@ -113,18 +113,13 @@ static int verify_packfile(struct packed_git *p,
113 p->pack_name, (uintmax_t)offset);
114 }
115 data = unpack_entry(p, entries[i].offset, &type, &size);
116 - if (!data) {
116 + if (!data)
117 err = error("cannot unpack %s from %s at offset %"PRIuMAX"",
118 sha1_to_hex(entries[i].sha1), p->pack_name,
119 (uintmax_t)entries[i].offset);
120 - break;
121 - }
122 - if (check_sha1_signature(entries[i].sha1, data, size, typename(type))) {
120 + else if (check_sha1_signature(entries[i].sha1, data, size, typename(type)))
121 err = error("packed %s from %s is corrupt",
122 sha1_to_hex(entries[i].sha1), p->pack_name);
125 - free(data);
126 - break;
127 - }
123 free(data);
124 }
125 free(entries);