]> git.ipfire.org Git - thirdparty/git.git/commitdiff
pack-bitmap: introduce function to check whether a pack is bitmapped
authorPatrick Steinhardt <ps@pks.im>
Wed, 2 Apr 2025 11:13:44 +0000 (13:13 +0200)
committerJunio C Hamano <gitster@pobox.com>
Mon, 7 Apr 2025 21:43:51 +0000 (14:43 -0700)
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>
pack-bitmap.c
pack-bitmap.h

index 6adb8aaa1c27f1f281111bd0435c717834f5a5a0..edc8f42122da94782c090970b4f9017b00b0313f 100644 (file)
@@ -745,6 +745,21 @@ struct bitmap_index *prepare_midx_bitmap_git(struct multi_pack_index *midx)
        return NULL;
 }
 
+int bitmap_index_contains_pack(struct bitmap_index *bitmap, struct packed_git *pack)
+{
+       for (; bitmap; bitmap = bitmap->base) {
+               if (bitmap_is_midx(bitmap)) {
+                       for (size_t i = 0; i < bitmap->midx->num_packs; i++)
+                               if (bitmap->midx->packs[i] == pack)
+                                       return 1;
+               } else if (bitmap->pack == pack) {
+                       return 1;
+               }
+       }
+
+       return 0;
+}
+
 struct include_data {
        struct bitmap_index *bitmap_git;
        struct bitmap *base;
index 079bae32466a3d747873d375ba0bba7cbea564bd..55df1b3af5af805507405047b51ee02aa2dfcab2 100644 (file)
@@ -67,6 +67,13 @@ struct bitmapped_pack {
 
 struct bitmap_index *prepare_bitmap_git(struct repository *r);
 struct bitmap_index *prepare_midx_bitmap_git(struct multi_pack_index *midx);
+
+/*
+ * Given a bitmap index, determine whether it contains the pack either directly
+ * or via the multi-pack-index.
+ */
+int bitmap_index_contains_pack(struct bitmap_index *bitmap, struct packed_git *pack);
+
 void count_bitmap_commit_list(struct bitmap_index *, uint32_t *commits,
                              uint32_t *trees, uint32_t *blobs, uint32_t *tags);
 void traverse_bitmap_commit_list(struct bitmap_index *,