]> git.ipfire.org Git - thirdparty/git.git/commitdiff
pack-bitmap: consolidate `find_object_pos()` success path
authorTaylor Blau <me@ttaylorr.com>
Wed, 27 May 2026 19:55:59 +0000 (15:55 -0400)
committerJunio C Hamano <gitster@pobox.com>
Wed, 27 May 2026 20:23:00 +0000 (05:23 +0900)
Both sides of `find_object_pos()` report success in the same way by
setting the optional `found` out-parameter and return the resolved
bitmap position.

Prepare for adding more bookkeeping around object-position lookups by
storing the result in a local `pos` variable and sharing the success
return path between the packlist and MIDX cases.

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

index 651ad467469f4413bce4a522fc63dee7b3b4e188..42ed22feacc70216db761f35a6d7766f6c3a837e 100644 (file)
@@ -217,6 +217,7 @@ static uint32_t find_object_pos(struct bitmap_writer *writer,
                                const struct object_id *oid, int *found)
 {
        struct object_entry *entry;
+       uint32_t pos;
 
        entry = packlist_find(writer->to_pack, oid);
        if (entry) {
@@ -224,23 +225,22 @@ static uint32_t find_object_pos(struct bitmap_writer *writer,
                if (writer->midx)
                        base_objects = writer->midx->num_objects +
                                writer->midx->num_objects_in_base;
-
-               if (found)
-                       *found = 1;
-               return oe_in_pack_pos(writer->to_pack, entry) + base_objects;
+               pos = oe_in_pack_pos(writer->to_pack, entry) + base_objects;
        } else if (writer->midx) {
-               uint32_t at, pos;
+               uint32_t at;
 
                if (!bsearch_midx(oid, writer->midx, &at))
                        goto missing;
                if (midx_to_pack_pos(writer->midx, at, &pos) < 0)
                        goto missing;
-
-               if (found)
-                       *found = 1;
-               return pos;
+       } else {
+               goto missing;
        }
 
+       if (found)
+               *found = 1;
+       return pos;
+
 missing:
        if (found)
                *found = 0;