]> git.ipfire.org Git - thirdparty/git.git/commitdiff
write_reused_pack_one(): convert to new revindex API
authorTaylor Blau <me@ttaylorr.com>
Wed, 13 Jan 2021 22:23:39 +0000 (17:23 -0500)
committerJunio C Hamano <gitster@pobox.com>
Thu, 14 Jan 2021 05:53:45 +0000 (21:53 -0800)
Replace direct revindex accesses with calls to 'pack_pos_to_offset()'
and 'pack_pos_to_index()'.

Signed-off-by: Taylor Blau <me@ttaylorr.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
builtin/pack-objects.c

index ab1fd853f1ea093659e101b738aa6f35501ca897..8e40b19ee8a6296d21234aac12d4c713f4649a3a 100644 (file)
@@ -868,8 +868,8 @@ static void write_reused_pack_one(size_t pos, struct hashfile *out,
        enum object_type type;
        unsigned long size;
 
-       offset = reuse_packfile->revindex[pos].offset;
-       next = reuse_packfile->revindex[pos + 1].offset;
+       offset = pack_pos_to_offset(reuse_packfile, pos);
+       next = pack_pos_to_offset(reuse_packfile, pos + 1);
 
        record_reused_object(offset, offset - hashfile_total(out));
 
@@ -889,11 +889,17 @@ static void write_reused_pack_one(size_t pos, struct hashfile *out,
 
                /* Convert to REF_DELTA if we must... */
                if (!allow_ofs_delta) {
-                       int base_pos = find_revindex_position(reuse_packfile, base_offset);
+                       uint32_t base_pos;
                        struct object_id base_oid;
 
+                       if (offset_to_pack_pos(reuse_packfile, base_offset, &base_pos) < 0)
+                               die(_("expected object at offset %"PRIuMAX" "
+                                     "in pack %s"),
+                                   (uintmax_t)base_offset,
+                                   reuse_packfile->pack_name);
+
                        nth_packed_object_id(&base_oid, reuse_packfile,
-                                            reuse_packfile->revindex[base_pos].nr);
+                                            pack_pos_to_index(reuse_packfile, base_pos));
 
                        len = encode_in_pack_object_header(header, sizeof(header),
                                                           OBJ_REF_DELTA, size);