summaryrefslogtreecommitdiff
path: root/pack-bitmap.c
diff options
context:
space:
mode:
authorLibravatar Taylor Blau <me@ttaylorr.com>2021-03-31 21:32:07 -0400
committerLibravatar Junio C Hamano <gitster@pobox.com>2021-03-31 23:14:03 -0700
commitdff5e49e51bfddbbeb5ed1f07031ccbd0bc216dc (patch)
tree89b2b55cb93ef11ec1fc0400c3c4c157281bcad8 /pack-bitmap.c
parentThe fifth batch (diff)
downloadtgif-dff5e49e51bfddbbeb5ed1f07031ccbd0bc216dc.tar.xz
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>
Diffstat (limited to 'pack-bitmap.c')
-rw-r--r--pack-bitmap.c18
1 files changed, 18 insertions, 0 deletions
diff --git a/pack-bitmap.c b/pack-bitmap.c
index 1ebe0c8162..7554510b14 100644
--- a/pack-bitmap.c
+++ b/pack-bitmap.c
@@ -1350,6 +1350,24 @@ void test_bitmap_walk(struct rev_info *revs)
free_bitmap_index(bitmap_git);
}
+int test_bitmap_commits(struct repository *r)
+{
+ struct bitmap_index *bitmap_git = prepare_bitmap_git(r);
+ struct object_id oid;
+ MAYBE_UNUSED void *value;
+
+ if (!bitmap_git)
+ die("failed to load bitmap indexes");
+
+ kh_foreach(bitmap_git->bitmaps, oid, value, {
+ printf("%s\n", oid_to_hex(&oid));
+ });
+
+ free_bitmap_index(bitmap_git);
+
+ return 0;
+}
+
int rebuild_bitmap(const uint32_t *reposition,
struct ewah_bitmap *source,
struct bitmap *dest)