Skip to content

Commit 83296d2

Browse files
ttaylorrgitster
authored andcommitted
pack-bitmap: return multiple packs via reuse_partial_packfile_from_bitmap()
Further prepare for enabling verbatim pack-reuse over multiple packfiles by changing the signature of reuse_partial_packfile_from_bitmap() to populate an array of `struct bitmapped_pack *`'s instead of a pointer to a single packfile. Since the array we're filling out is sized dynamically[^1], add an additional `size_t *` parameter which will hold the number of reusable packs (equal to the number of elements in the array). Note that since we still have not implemented true multi-pack reuse, these changes aren't propagated out to the rest of the caller in builtin/pack-objects.c. In the interim state, we expect that the array has a single element, and we use that element to fill out the static `reuse_packfile` variable (which is a bog-standard `struct packed_git *`). Future commits will continue to push this change further out through the pack-objects code. [^1]: That is, even though we know the number of packs which are candidates for pack-reuse, we do not know how many of those candidates we can actually reuse. Signed-off-by: Taylor Blau <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent 35e156b commit 83296d2

File tree

3 files changed

+14
-6
lines changed

3 files changed

+14
-6
lines changed

builtin/pack-objects.c

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3940,14 +3940,19 @@ static int pack_options_allow_reuse(void)
39403940

39413941
static int get_object_list_from_bitmap(struct rev_info *revs)
39423942
{
3943+
struct bitmapped_pack *packs = NULL;
3944+
size_t packs_nr = 0;
3945+
39433946
if (!(bitmap_git = prepare_bitmap_walk(revs, 0)))
39443947
return -1;
39453948

39463949
if (pack_options_allow_reuse())
3947-
reuse_partial_packfile_from_bitmap(bitmap_git, &reuse_packfile,
3950+
reuse_partial_packfile_from_bitmap(bitmap_git, &packs,
3951+
&packs_nr,
39483952
&reuse_packfile_bitmap);
39493953

3950-
if (reuse_packfile) {
3954+
if (packs) {
3955+
reuse_packfile = packs[0].p;
39513956
reuse_packfile_objects = bitmap_popcount(reuse_packfile_bitmap);
39523957
if (!reuse_packfile_objects)
39533958
BUG("expected non-empty reuse bitmap");

pack-bitmap.c

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2001,7 +2001,8 @@ static int bitmapped_pack_cmp(const void *va, const void *vb)
20012001
}
20022002

20032003
void reuse_partial_packfile_from_bitmap(struct bitmap_index *bitmap_git,
2004-
struct packed_git **packfile_out,
2004+
struct bitmapped_pack **packs_out,
2005+
size_t *packs_nr_out,
20052006
struct bitmap **reuse_out)
20062007
{
20072008
struct repository *r = the_repository;
@@ -2069,7 +2070,8 @@ void reuse_partial_packfile_from_bitmap(struct bitmap_index *bitmap_git,
20692070
* need to be handled separately.
20702071
*/
20712072
bitmap_and_not(result, reuse);
2072-
*packfile_out = packs[0].p;
2073+
*packs_out = packs;
2074+
*packs_nr_out = packs_nr;
20732075
*reuse_out = reuse;
20742076
}
20752077

pack-bitmap.h

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -78,8 +78,9 @@ int test_bitmap_hashes(struct repository *r);
7878
struct bitmap_index *prepare_bitmap_walk(struct rev_info *revs,
7979
int filter_provided_objects);
8080
uint32_t midx_preferred_pack(struct bitmap_index *bitmap_git);
81-
void reuse_partial_packfile_from_bitmap(struct bitmap_index *,
82-
struct packed_git **packfile,
81+
void reuse_partial_packfile_from_bitmap(struct bitmap_index *bitmap_git,
82+
struct bitmapped_pack **packs_out,
83+
size_t *packs_nr_out,
8384
struct bitmap **reuse_out);
8485
int rebuild_existing_bitmaps(struct bitmap_index *, struct packing_data *mapping,
8586
kh_oid_map_t *reused_bitmaps, int show_progress);

0 commit comments

Comments
 (0)