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>
This commit is contained in:
Patrick Steinhardt
2025-04-02 13:13:44 +02:00
committed by Junio C Hamano
parent 5420901bde
commit c9b94a7785
2 changed files with 22 additions and 0 deletions

View 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;