Skip to content

Commit 35e156b

Browse files
ttaylorrgitster
authored andcommitted
pack-bitmap: simplify reuse_partial_packfile_from_bitmap() signature
The signature of `reuse_partial_packfile_from_bitmap()` currently takes in a bitmap, as well as three output parameters (filled through pointers, and passed as arguments), and also returns an integer result. The output parameters are filled out with: (a) the packfile used for pack-reuse, (b) the number of objects from that pack that we can reuse, and (c) a bitmap indicating which objects we can reuse. The return value is either -1 (when there are no objects to reuse), or 0 (when there is at least one object to reuse). Some of these parameters are redundant. Notably, we can infer from the bitmap how many objects are reused by calling bitmap_popcount(). And we can similar compute the return value based on that number as well. As such, clean up the signature of this function to drop the "*entries" parameter, as well as the int return value, since the single caller of this function can infer these values themself. Signed-off-by: Taylor Blau <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent e5d48bf commit 35e156b

File tree

3 files changed

+19
-20
lines changed

3 files changed

+19
-20
lines changed

builtin/pack-objects.c

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -3943,13 +3943,15 @@ static int get_object_list_from_bitmap(struct rev_info *revs)
39433943
if (!(bitmap_git = prepare_bitmap_walk(revs, 0)))
39443944
return -1;
39453945

3946-
if (pack_options_allow_reuse() &&
3947-
!reuse_partial_packfile_from_bitmap(
3948-
bitmap_git,
3949-
&reuse_packfile,
3950-
&reuse_packfile_objects,
3951-
&reuse_packfile_bitmap)) {
3952-
assert(reuse_packfile_objects);
3946+
if (pack_options_allow_reuse())
3947+
reuse_partial_packfile_from_bitmap(bitmap_git, &reuse_packfile,
3948+
&reuse_packfile_bitmap);
3949+
3950+
if (reuse_packfile) {
3951+
reuse_packfile_objects = bitmap_popcount(reuse_packfile_bitmap);
3952+
if (!reuse_packfile_objects)
3953+
BUG("expected non-empty reuse bitmap");
3954+
39533955
nr_result += reuse_packfile_objects;
39543956
nr_seen += reuse_packfile_objects;
39553957
display_progress(progress_state, nr_seen);

pack-bitmap.c

Lines changed: 7 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -2000,10 +2000,9 @@ static int bitmapped_pack_cmp(const void *va, const void *vb)
20002000
return 0;
20012001
}
20022002

2003-
int reuse_partial_packfile_from_bitmap(struct bitmap_index *bitmap_git,
2004-
struct packed_git **packfile_out,
2005-
uint32_t *entries,
2006-
struct bitmap **reuse_out)
2003+
void reuse_partial_packfile_from_bitmap(struct bitmap_index *bitmap_git,
2004+
struct packed_git **packfile_out,
2005+
struct bitmap **reuse_out)
20072006
{
20082007
struct repository *r = the_repository;
20092008
struct bitmapped_pack *packs = NULL;
@@ -2025,7 +2024,7 @@ int reuse_partial_packfile_from_bitmap(struct bitmap_index *bitmap_git,
20252024
warning(_("unable to load pack: '%s', disabling pack-reuse"),
20262025
bitmap_git->midx->pack_names[i]);
20272026
free(packs);
2028-
return -1;
2027+
return;
20292028
}
20302029
if (!pack.bitmap_nr)
20312030
continue; /* no objects from this pack */
@@ -2059,10 +2058,10 @@ int reuse_partial_packfile_from_bitmap(struct bitmap_index *bitmap_git,
20592058

20602059
reuse_partial_packfile_from_bitmap_1(bitmap_git, packs, reuse);
20612060

2062-
*entries = bitmap_popcount(reuse);
2063-
if (!*entries) {
2061+
if (bitmap_is_empty(reuse)) {
2062+
free(packs);
20642063
bitmap_free(reuse);
2065-
return -1;
2064+
return;
20662065
}
20672066

20682067
/*
@@ -2072,7 +2071,6 @@ int reuse_partial_packfile_from_bitmap(struct bitmap_index *bitmap_git,
20722071
bitmap_and_not(result, reuse);
20732072
*packfile_out = packs[0].p;
20742073
*reuse_out = reuse;
2075-
return 0;
20762074
}
20772075

20782076
int bitmap_walk_contains(struct bitmap_index *bitmap_git,

pack-bitmap.h

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -78,10 +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-
int reuse_partial_packfile_from_bitmap(struct bitmap_index *,
82-
struct packed_git **packfile,
83-
uint32_t *entries,
84-
struct bitmap **reuse_out);
81+
void reuse_partial_packfile_from_bitmap(struct bitmap_index *,
82+
struct packed_git **packfile,
83+
struct bitmap **reuse_out);
8584
int rebuild_existing_bitmaps(struct bitmap_index *, struct packing_data *mapping,
8685
kh_oid_map_t *reused_bitmaps, int show_progress);
8786
void free_bitmap_index(struct bitmap_index *);

0 commit comments

Comments
 (0)