Introduce a function that allows us to verify whether a pack is bitmapped or not. This functionality will be used in a subsequent commit. Signed-off-by: Patrick Steinhardt <ps@xxxxxx> --- pack-bitmap.c | 15 +++++++++++++++ pack-bitmap.h | 7 +++++++ 2 files changed, 22 insertions(+) diff --git a/pack-bitmap.c b/pack-bitmap.c index fc92e0aae65..3cbe5bfe909 100644 --- a/pack-bitmap.c +++ b/pack-bitmap.c @@ -658,6 +658,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) +{ + if (bitmap->pack) + return bitmap->pack == pack; + + if (!bitmap->midx->chunk_bitmapped_packs) + return 0; + + for (size_t i = 0; i < bitmap->midx->num_packs; i++) + if (bitmap->midx->packs[i] == pack) + return 1; + + return 0; +} + struct include_data { struct bitmap_index *bitmap_git; struct bitmap *base; diff --git a/pack-bitmap.h b/pack-bitmap.h index 3368e79ed5a..45e96b213e2 100644 --- a/pack-bitmap.h +++ b/pack-bitmap.h @@ -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 *, -- 2.48.1.683.gf705b3209c.dirty