Skip to content

Commit e31c710

Browse files
peffgitster
authored andcommitted
pack-check: convert "internal error" die to a BUG()
If we fail to load the oid from the index of a packfile, we'll die() with an "internal error". But this should never happen: we'd fail here only if the idx needed to be lazily opened (but we've already opened it) or if we asked for an out-of-range index (but we're iterating using the same count that we'd check the range against). A corrupted index might have a bogus count (e.g., too large for its size), but we'd have complained and aborted already when opening the index initially. While we're here, we can add a few details so that if this bug ever _does_ trigger, we'll have a bit more information. Signed-off-by: Jeff King <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent 500e4f2 commit e31c710

File tree

1 file changed

+2
-1
lines changed

1 file changed

+2
-1
lines changed

pack-check.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -99,7 +99,8 @@ static int verify_packfile(struct repository *r,
9999
for (i = 0; i < nr_objects; i++) {
100100
entries[i].oid.hash = nth_packed_object_sha1(p, i);
101101
if (!entries[i].oid.hash)
102-
die("internal error pack-check nth-packed-object");
102+
BUG("unable to get oid of object %lu from %s",
103+
(unsigned long)i, p->pack_name);
103104
entries[i].offset = nth_packed_object_offset(p, i);
104105
entries[i].nr = i;
105106
}

0 commit comments

Comments
 (0)