]> git.ipfire.org Git - thirdparty/git.git/commitdiff
pack-bitmap: add 'test_bitmap_commits()' helper
authorTaylor Blau <me@ttaylorr.com>
Thu, 1 Apr 2021 01:32:07 +0000 (21:32 -0400)
committerJunio C Hamano <gitster@pobox.com>
Thu, 1 Apr 2021 06:14:03 +0000 (23:14 -0700)
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>
pack-bitmap.c
pack-bitmap.h

index 1ebe0c81628a35932c3d05ccb1306834442568a0..7554510b140d4b4b366d4c4ea121a9e87d3451a2 100644 (file)
@@ -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)
index 36d99930d8d5288a7367235eba8d533ed8f76f99..c3cdd80756ca401a8ee687a9d21a6f2137bcfb67 100644 (file)
@@ -49,6 +49,7 @@ void traverse_bitmap_commit_list(struct bitmap_index *,
                                 struct rev_info *revs,
                                 show_reachable_fn show_reachable);
 void test_bitmap_walk(struct rev_info *revs);
+int test_bitmap_commits(struct repository *r);
 struct bitmap_index *prepare_bitmap_walk(struct rev_info *revs,
                                         struct list_objects_filter_options *filter);
 int reuse_partial_packfile_from_bitmap(struct bitmap_index *,