Skip to content

Commit dff5e49

Browse files
ttaylorrgitster
authored andcommitted
pack-bitmap: add 'test_bitmap_commits()' helper
The next patch will add a 'bitmap' test-tool which prints the list of commits that have bitmaps computed. The test helper could implement this itself, but it would need access to the 'bitmaps' field of the 'pack_bitmap' struct. To avoid exposing this private detail, implement the entirety of the helper behind a test_bitmap_commits() function in pack-bitmap.c. There is some precedence for this with test_bitmap_walk() which is used to implement the '--test-bitmap' flag in 'git rev-list' (and is also implemented in pack-bitmap.c). A caller will be added in the next patch. Signed-off-by: Taylor Blau <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent a65ce7f commit dff5e49

File tree

2 files changed

+19
-0
lines changed

2 files changed

+19
-0
lines changed

pack-bitmap.c

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1350,6 +1350,24 @@ void test_bitmap_walk(struct rev_info *revs)
13501350
free_bitmap_index(bitmap_git);
13511351
}
13521352

1353+
int test_bitmap_commits(struct repository *r)
1354+
{
1355+
struct bitmap_index *bitmap_git = prepare_bitmap_git(r);
1356+
struct object_id oid;
1357+
MAYBE_UNUSED void *value;
1358+
1359+
if (!bitmap_git)
1360+
die("failed to load bitmap indexes");
1361+
1362+
kh_foreach(bitmap_git->bitmaps, oid, value, {
1363+
printf("%s\n", oid_to_hex(&oid));
1364+
});
1365+
1366+
free_bitmap_index(bitmap_git);
1367+
1368+
return 0;
1369+
}
1370+
13531371
int rebuild_bitmap(const uint32_t *reposition,
13541372
struct ewah_bitmap *source,
13551373
struct bitmap *dest)

pack-bitmap.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,7 @@ void traverse_bitmap_commit_list(struct bitmap_index *,
4949
struct rev_info *revs,
5050
show_reachable_fn show_reachable);
5151
void test_bitmap_walk(struct rev_info *revs);
52+
int test_bitmap_commits(struct repository *r);
5253
struct bitmap_index *prepare_bitmap_walk(struct rev_info *revs,
5354
struct list_objects_filter_options *filter);
5455
int reuse_partial_packfile_from_bitmap(struct bitmap_index *,

0 commit comments

Comments
 (0)