]> git.ipfire.org Git - thirdparty/git.git/commitdiff
check_object(): convert to new revindex API
authorTaylor Blau <me@ttaylorr.com>
Wed, 13 Jan 2021 22:23:47 +0000 (17:23 -0500)
committerJunio C Hamano <gitster@pobox.com>
Thu, 14 Jan 2021 05:53:45 +0000 (21:53 -0800)
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 <me@ttaylorr.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
builtin/pack-objects.c

index 77ce5583a29ff13cf47b5dd0bdc14ca270a58f6a..5b0c4489e27d48f2af3729c991e258c3150c2be0 100644 (file)
@@ -1817,11 +1817,11 @@ static void check_object(struct object_entry *entry, uint32_t object_index)
                                goto give_up;
                        }
                        if (reuse_delta && !entry->preferred_base) {
-                               struct revindex_entry *revidx;
-                               revidx = find_pack_revindex(p, ofs);
-                               if (!revidx)
+                               uint32_t pos;
+                               if (offset_to_pack_pos(p, ofs, &pos) < 0)
                                        goto give_up;
-                               if (!nth_packed_object_id(&base_ref, p, revidx->nr))
+                               if (!nth_packed_object_id(&base_ref, p,
+                                                         pack_pos_to_index(p, pos)))
                                        have_base = 1;
                        }
                        entry->in_pack_header_size = used + used_0;