Skip to content

Commit 60750e1

Browse files
ttaylorrgitster
authored andcommitted
midx: teach nth_bitmapped_pack() about incremental MIDXs
In a similar fashion as in previous commits, teach the function `nth_bitmapped_pack()` about incremental MIDXs by translating the given `pack_int_id` from the concatenated lexical order to a MIDX-local lexical position. When accessing the containing MIDX's array of packs, use the local pack ID. Likewise, when reading the 'BTMP' chunk, use the MIDX-local offset when accessing the data within that chunk. (Note that the both the call to prepare_midx_pack() and the assignment of bp->pack_int_id both care about the global pack_int_id, so avoid shadowing the given 'pack_int_id' parameter). Signed-off-by: Taylor Blau <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent 26afb5a commit 60750e1

File tree

1 file changed

+5
-3
lines changed

1 file changed

+5
-3
lines changed

midx.c

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -311,17 +311,19 @@ int prepare_midx_pack(struct repository *r, struct multi_pack_index *m,
311311
int nth_bitmapped_pack(struct repository *r, struct multi_pack_index *m,
312312
struct bitmapped_pack *bp, uint32_t pack_int_id)
313313
{
314+
uint32_t local_pack_int_id = midx_for_pack(&m, pack_int_id);
315+
314316
if (!m->chunk_bitmapped_packs)
315317
return error(_("MIDX does not contain the BTMP chunk"));
316318

317319
if (prepare_midx_pack(r, m, pack_int_id))
318320
return error(_("could not load bitmapped pack %"PRIu32), pack_int_id);
319321

320-
bp->p = m->packs[pack_int_id];
322+
bp->p = m->packs[local_pack_int_id];
321323
bp->bitmap_pos = get_be32((char *)m->chunk_bitmapped_packs +
322-
MIDX_CHUNK_BITMAPPED_PACKS_WIDTH * pack_int_id);
324+
MIDX_CHUNK_BITMAPPED_PACKS_WIDTH * local_pack_int_id);
323325
bp->bitmap_nr = get_be32((char *)m->chunk_bitmapped_packs +
324-
MIDX_CHUNK_BITMAPPED_PACKS_WIDTH * pack_int_id +
326+
MIDX_CHUNK_BITMAPPED_PACKS_WIDTH * local_pack_int_id +
325327
sizeof(uint32_t));
326328
bp->pack_int_id = pack_int_id;
327329

0 commit comments

Comments
 (0)