Skip to content

Commit 0842bae

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. Signed-off-by: Patrick Steinhardt <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent 22cc754 commit 0842bae

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
@@ -658,6 +658,21 @@ struct bitmap_index *prepare_midx_bitmap_git(struct multi_pack_index *midx)
658658
return NULL;
659659
}
660660

661+
int bitmap_index_contains_pack(struct bitmap_index *bitmap, struct packed_git *pack)
662+
{
663+
if (bitmap->pack)
664+
return bitmap->pack == pack;
665+
666+
if (!bitmap->midx->chunk_bitmapped_packs)
667+
return 0;
668+
669+
for (size_t i = 0; i < bitmap->midx->num_packs; i++)
670+
if (bitmap->midx->packs[i] == pack)
671+
return 1;
672+
673+
return 0;
674+
}
675+
661676
struct include_data {
662677
struct bitmap_index *bitmap_git;
663678
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)