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 <me@ttaylorr.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
Taylor Blau committed
Mar 31, 2021 at 21:32 UTC
dff5e49e51bfddbbeb5ed1f07031ccbd0bc216dc
2 files changed
+19
pack-bitmap.c
+18
@@ -1350,6 +1350,24 @@ void test_bitmap_walk(struct rev_info *revs)
1350
free_bitmap_index(bitmap_git);
1351
}
1352
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
+
1371
int rebuild_bitmap(const uint32_t *reposition,
1372
struct ewah_bitmap *source,
1373
struct bitmap *dest)
pack-bitmap.h
+1
@@ -49,6 +49,7 @@ void traverse_bitmap_commit_list(struct bitmap_index *,
49
struct rev_info *revs,
50
show_reachable_fn show_reachable);
51
void test_bitmap_walk(struct rev_info *revs);
52
+int test_bitmap_commits(struct repository *r);
53
struct bitmap_index *prepare_bitmap_walk(struct rev_info *revs,
54
struct list_objects_filter_options *filter);
55
int reuse_partial_packfile_from_bitmap(struct bitmap_index *,