]> git.ipfire.org Git - thirdparty/git.git/commitdiff
midx-write.c: enumerate `pack_int_id` values directly
authorTaylor Blau <me@ttaylorr.com>
Sat, 6 Dec 2025 20:31:37 +0000 (15:31 -0500)
committerJunio C Hamano <gitster@pobox.com>
Sat, 6 Dec 2025 22:38:09 +0000 (07:38 +0900)
Our `midx-write.c::fill_packs_from_midx()` function currently enumerates
the range [0, m->num_packs), and then shifts its index variable up by
`m->num_packs_in_base` to produce a valid `pack_int_id`.

Instead, directly enumerate the range:

    [m->num_packs_in_base, m->num_packs_in_base + m->num_packs)

, which are the original pack_int_ids themselves as opposed to the
indexes of those packs relative to the MIDX layer they are contained
within.

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

index 5927691f6a0ed1008c20c7310747ebdccd14c9c6..d3644276aad1ae48d7ac73f2641c45cc06b57bc5 100644 (file)
@@ -932,11 +932,11 @@ static int fill_packs_from_midx(struct write_midx_context *ctx)
        for (m = ctx->m; m; m = m->base_midx) {
                uint32_t i;
 
-               for (i = 0; i < m->num_packs; i++) {
+               for (i = m->num_packs_in_base;
+                    i < m->num_packs_in_base + m->num_packs; i++) {
                        ALLOC_GROW(ctx->info, ctx->nr + 1, ctx->alloc);
 
-                       if (fill_pack_from_midx(&ctx->info[ctx->nr], m,
-                                               m->num_packs_in_base + i) < 0)
+                       if (fill_pack_from_midx(&ctx->info[ctx->nr], m, i) < 0)
                                return -1;
 
                        ctx->nr++;