summaryrefslogtreecommitdiff
path: root/pack-check.c
diff options
context:
space:
mode:
Diffstat (limited to 'pack-check.c')
-rw-r--r--pack-check.c22
1 files changed, 10 insertions, 12 deletions
diff --git a/pack-check.c b/pack-check.c
index e4ef71c673..dad6d8ae7f 100644
--- a/pack-check.c
+++ b/pack-check.c
@@ -8,10 +8,6 @@
struct idx_entry {
off_t offset;
- union idx_entry_object {
- const unsigned char *hash;
- struct object_id *oid;
- } oid;
unsigned int nr;
};
@@ -97,9 +93,6 @@ static int verify_packfile(struct repository *r,
entries[nr_objects].offset = pack_sig_ofs;
/* first sort entries by pack offset, since unpacking them is more efficient that way */
for (i = 0; i < nr_objects; i++) {
- entries[i].oid.hash = nth_packed_object_sha1(p, i);
- if (!entries[i].oid.hash)
- die("internal error pack-check nth-packed-object");
entries[i].offset = nth_packed_object_offset(p, i);
entries[i].nr = i;
}
@@ -107,11 +100,16 @@ static int verify_packfile(struct repository *r,
for (i = 0; i < nr_objects; i++) {
void *data;
+ struct object_id oid;
enum object_type type;
unsigned long size;
off_t curpos;
int data_valid;
+ if (nth_packed_object_id(&oid, p, entries[i].nr) < 0)
+ BUG("unable to get oid of object %lu from %s",
+ (unsigned long)entries[i].nr, p->pack_name);
+
if (p->index_version > 1) {
off_t offset = entries[i].offset;
off_t len = entries[i+1].offset - offset;
@@ -119,7 +117,7 @@ static int verify_packfile(struct repository *r,
if (check_pack_crc(p, w_curs, offset, len, nr))
err = error("index CRC mismatch for object %s "
"from %s at offset %"PRIuMAX"",
- oid_to_hex(entries[i].oid.oid),
+ oid_to_hex(&oid),
p->pack_name, (uintmax_t)offset);
}
@@ -142,14 +140,14 @@ static int verify_packfile(struct repository *r,
if (data_valid && !data)
err = error("cannot unpack %s from %s at offset %"PRIuMAX"",
- oid_to_hex(entries[i].oid.oid), p->pack_name,
+ oid_to_hex(&oid), p->pack_name,
(uintmax_t)entries[i].offset);
- else if (check_object_signature(r, entries[i].oid.oid, data, size, type_name(type)))
+ else if (check_object_signature(r, &oid, data, size, type_name(type)))
err = error("packed %s from %s is corrupt",
- oid_to_hex(entries[i].oid.oid), p->pack_name);
+ oid_to_hex(&oid), p->pack_name);
else if (fn) {
int eaten = 0;
- err |= fn(entries[i].oid.oid, type, size, data, &eaten);
+ err |= fn(&oid, type, size, data, &eaten);
if (eaten)
data = NULL;
}