@matheusbsbs / matheus-bagliano / commits / 40d18ff8c6
Fork 0

pack-bitmap: introduce bitmap_walk_contains()

We will use this helper function in a following commit to tell us if an object is packed. Signed-off-by: Jeff King <peff@peff.net> Signed-off-by: Christian Couder <chriscool@tuxfamily.org> Signed-off-by: Junio C Hamano <gitster@pobox.com>

Jeff King committed Dec 18, 2019 at 12:25 UTC 40d18ff8c6b6977eaf8450dc4eeb866ece5298fc
2 files changed +15
pack-bitmap.c
+12
@@ -832,6 +832,18 @@ int reuse_partial_packfile_from_bitmap(struct bitmap_index *bitmap_git,
832 return 0;
833 }
834
835 +int bitmap_walk_contains(struct bitmap_index *bitmap_git,
836 + struct bitmap *bitmap, const struct object_id *oid)
837 +{
838 + int idx;
839 +
840 + if (!bitmap)
841 + return 0;
842 +
843 + idx = bitmap_position(bitmap_git, oid);
844 + return idx >= 0 && bitmap_get(bitmap, idx);
845 +}
846 +
847 void traverse_bitmap_commit_list(struct bitmap_index *bitmap_git,
848 show_reachable_fn show_reachable)
849 {
pack-bitmap.h
+3
@@ -3,6 +3,7 @@
3
4 #include "ewah/ewok.h"
5 #include "khash.h"
6 +#include "pack.h"
7 #include "pack-objects.h"
8
9 struct commit;
@@ -53,6 +54,8 @@ int reuse_partial_packfile_from_bitmap(struct bitmap_index *,
54 int rebuild_existing_bitmaps(struct bitmap_index *, struct packing_data *mapping,
55 kh_oid_map_t *reused_bitmaps, int show_progress);
56 void free_bitmap_index(struct bitmap_index *);
57 +int bitmap_walk_contains(struct bitmap_index *,
58 + struct bitmap *bitmap, const struct object_id *oid);
59
60 /*
61 * After a traversal has been performed by prepare_bitmap_walk(), this can be