Skip to content

Commit 3886c72

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 largest number of reusable sections. Signed-off-by: Taylor Blau <[email protected]> Acked-by: Elijah Newren <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent f77dbf0 commit 3886c72

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
@@ -2335,7 +2335,8 @@ void reuse_partial_packfile_from_bitmap(struct bitmap_index *bitmap_git,
23352335
multi_pack_reuse = 0;
23362336

23372337
if (multi_pack_reuse) {
2338-
for (i = 0; i < bitmap_git->midx->num_packs; i++) {
2338+
struct multi_pack_index *m = bitmap_git->midx;
2339+
for (i = 0; i < m->num_packs + m->num_packs_in_base; i++) {
23392340
struct bitmapped_pack pack;
23402341
if (nth_bitmapped_pack(r, bitmap_git->midx, &pack, i) < 0) {
23412342
warning(_("unable to load pack: '%s', disabling pack-reuse"),
@@ -2361,14 +2362,18 @@ void reuse_partial_packfile_from_bitmap(struct bitmap_index *bitmap_git,
23612362
uint32_t pack_int_id;
23622363

23632364
if (bitmap_is_midx(bitmap_git)) {
2365+
struct multi_pack_index *m = bitmap_git->midx;
23642366
uint32_t preferred_pack_pos;
23652367

2366-
if (midx_preferred_pack(bitmap_git->midx, &preferred_pack_pos) < 0) {
2368+
while (m->base_midx)
2369+
m = m->base_midx;
2370+
2371+
if (midx_preferred_pack(m, &preferred_pack_pos) < 0) {
23672372
warning(_("unable to compute preferred pack, disabling pack-reuse"));
23682373
return;
23692374
}
23702375

2371-
pack = bitmap_git->midx->packs[preferred_pack_pos];
2376+
pack = nth_midxed_pack(m, preferred_pack_pos);
23722377
pack_int_id = preferred_pack_pos;
23732378
} else {
23742379
pack = bitmap_git->pack;

0 commit comments

Comments
 (0)