Skip to content

Commit c9b94a7

Browse files
pks-tgitster
authored andcommitted
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 <[email protected]> Signed-off-by: Patrick Steinhardt <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent 5420901 commit c9b94a7

File tree

2 files changed

+22
-0
lines changed

2 files changed

+22
-0
lines changed

pack-bitmap.c

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -745,6 +745,21 @@ struct bitmap_index *prepare_midx_bitmap_git(struct multi_pack_index *midx)
745745
return NULL;
746746
}
747747

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+
748763
struct include_data {
749764
struct bitmap_index *bitmap_git;
750765
struct bitmap *base;

pack-bitmap.h

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -67,6 +67,13 @@ struct bitmapped_pack {
6767

6868
struct bitmap_index *prepare_bitmap_git(struct repository *r);
6969
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+
7077
void count_bitmap_commit_list(struct bitmap_index *, uint32_t *commits,
7178
uint32_t *trees, uint32_t *blobs, uint32_t *tags);
7279
void traverse_bitmap_commit_list(struct bitmap_index *,

0 commit comments

Comments
 (0)