pack-bitmap: introduce function to check whether a pack is bitmapped
Introduce a function that allows us to verify whether a pack is bitmapped or not. This functionality will be used in a subsequent commit. Helped-by: Taylor Blau <me@ttaylorr.com> Signed-off-by: Patrick Steinhardt <ps@pks.im> Signed-off-by: Junio C Hamano <gitster@pobox.com>
Patrick Steinhardt committed
Apr 2, 2025 at 13:13 UTC
c9b94a7785b4de4e3e15d0e5b65c97337c206b81
2 files changed
+22
pack-bitmap.c
+15
@@ -745,6 +745,21 @@ struct bitmap_index *prepare_midx_bitmap_git(struct multi_pack_index *midx)
745
return NULL;
746
}
747
748
+int bitmap_index_contains_pack(struct bitmap_index *bitmap, struct packed_git *pack)
749
+{
750
+ for (; bitmap; bitmap = bitmap->base) {
751
+ if (bitmap_is_midx(bitmap)) {
752
+ for (size_t i = 0; i < bitmap->midx->num_packs; i++)
753
+ if (bitmap->midx->packs[i] == pack)
754
+ return 1;
755
+ } else if (bitmap->pack == pack) {
756
+ return 1;
757
+ }
758
+ }
759
+
760
+ return 0;
761
+}
762
+
763
struct include_data {
764
struct bitmap_index *bitmap_git;
765
struct bitmap *base;
pack-bitmap.h
+7
@@ -67,6 +67,13 @@ struct bitmapped_pack {
67
68
struct bitmap_index *prepare_bitmap_git(struct repository *r);
69
struct bitmap_index *prepare_midx_bitmap_git(struct multi_pack_index *midx);
70
+
71
+/*
72
+ * Given a bitmap index, determine whether it contains the pack either directly
73
+ * or via the multi-pack-index.
74
+ */
75
+int bitmap_index_contains_pack(struct bitmap_index *bitmap, struct packed_git *pack);
76
+
77
void count_bitmap_commit_list(struct bitmap_index *, uint32_t *commits,
78
uint32_t *trees, uint32_t *blobs, uint32_t *tags);
79
void traverse_bitmap_commit_list(struct bitmap_index *,