[PATCH v2 14/18] midx-write.c: enumerate `pack_int_id` values directly
- From
Taylor Blau <me@ttaylorr.com>
- Date
- Jan 14, 2026, 19:54 UTC
- Message-ID
- <c6f8d323477e9e74ce038b111d400c706f535676.1768420450.git.me@ttaylorr.com>
- In-Reply-To
- <cover.1768420450.git.me@ttaylorr.com>
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> --- midx-write.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-)
diff --git a/midx-write.c b/midx-write.c index c54113cdc84..80334914d3e 100644 --- a/midx-write.c +++ b/midx-write.c @@ -935,11 +935,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++;
-- 2.52.0.457.gb599f1ad4b0