Skip to content

Commit cee4f3c

Browse files
ttaylorrgitster
authored andcommitted
pack-bitmap.c: support bitmap pack-reuse with incremental MIDXs
In a similar fashion as previous commits in the first phase of incremental MIDXs, enumerate not just the packs in the current incremental MIDX layer, but previous ones as well. Likewise, in reuse_partial_packfile_from_bitmap(), when reusing only a single pack from a MIDX, use the oldest layer's preferred pack as it is likely to contain the most amount of reusable sections. Signed-off-by: Taylor Blau <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent 07e3df9 commit cee4f3c

File tree

1 file changed

+8
-3
lines changed

1 file changed

+8
-3
lines changed

pack-bitmap.c

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2320,7 +2320,8 @@ void reuse_partial_packfile_from_bitmap(struct bitmap_index *bitmap_git,
23202320
multi_pack_reuse = 0;
23212321

23222322
if (multi_pack_reuse) {
2323-
for (i = 0; i < bitmap_git->midx->num_packs; i++) {
2323+
struct multi_pack_index *m = bitmap_git->midx;
2324+
for (i = 0; i < m->num_packs + m->num_packs_in_base; i++) {
23242325
struct bitmapped_pack pack;
23252326
if (nth_bitmapped_pack(r, bitmap_git->midx, &pack, i) < 0) {
23262327
warning(_("unable to load pack: '%s', disabling pack-reuse"),
@@ -2344,14 +2345,18 @@ void reuse_partial_packfile_from_bitmap(struct bitmap_index *bitmap_git,
23442345
uint32_t pack_int_id;
23452346

23462347
if (bitmap_is_midx(bitmap_git)) {
2348+
struct multi_pack_index *m = bitmap_git->midx;
23472349
uint32_t preferred_pack_pos;
23482350

2349-
if (midx_preferred_pack(bitmap_git->midx, &preferred_pack_pos) < 0) {
2351+
while (m->base_midx)
2352+
m = m->base_midx;
2353+
2354+
if (midx_preferred_pack(m, &preferred_pack_pos) < 0) {
23502355
warning(_("unable to compute preferred pack, disabling pack-reuse"));
23512356
return;
23522357
}
23532358

2354-
pack = bitmap_git->midx->packs[preferred_pack_pos];
2359+
pack = nth_midxed_pack(m, preferred_pack_pos);
23552360
pack_int_id = preferred_pack_pos;
23562361
} else {
23572362
pack = bitmap_git->pack;

0 commit comments

Comments
 (0)