Skip to content

Commit eb3fd99

Browse files
ttaylorrgitster
authored andcommitted
check_object(): convert to new revindex API
Replace direct accesses to the revindex with calls to 'offset_to_pack_pos()' and 'pack_pos_to_index()'. Since this caller already had some error checking (it can jump to the 'give_up' label if it encounters an error), we can easily check whether or not the provided offset points to an object in the given pack. This error checking existed prior to this patch, too, since the caller checks whether the return value from 'find_pack_revindex()' was NULL or not. Signed-off-by: Taylor Blau <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent 6a5c10c commit eb3fd99

File tree

1 file changed

+4
-4
lines changed

1 file changed

+4
-4
lines changed

builtin/pack-objects.c

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1817,11 +1817,11 @@ static void check_object(struct object_entry *entry, uint32_t object_index)
18171817
goto give_up;
18181818
}
18191819
if (reuse_delta && !entry->preferred_base) {
1820-
struct revindex_entry *revidx;
1821-
revidx = find_pack_revindex(p, ofs);
1822-
if (!revidx)
1820+
uint32_t pos;
1821+
if (offset_to_pack_pos(p, ofs, &pos) < 0)
18231822
goto give_up;
1824-
if (!nth_packed_object_id(&base_ref, p, revidx->nr))
1823+
if (!nth_packed_object_id(&base_ref, p,
1824+
pack_pos_to_index(p, pos)))
18251825
have_base = 1;
18261826
}
18271827
entry->in_pack_header_size = used + used_0;

0 commit comments

Comments
 (0)