Skip to content

Commit 40d18ff

Browse files
peffgitster
authored andcommitted
pack-bitmap: introduce bitmap_walk_contains()
We will use this helper function in a following commit to tell us if an object is packed. Signed-off-by: Jeff King <[email protected]> Signed-off-by: Christian Couder <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent 14fbd26 commit 40d18ff

File tree

2 files changed

+15
-0
lines changed

2 files changed

+15
-0
lines changed

pack-bitmap.c

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -832,6 +832,18 @@ int reuse_partial_packfile_from_bitmap(struct bitmap_index *bitmap_git,
832832
return 0;
833833
}
834834

835+
int bitmap_walk_contains(struct bitmap_index *bitmap_git,
836+
struct bitmap *bitmap, const struct object_id *oid)
837+
{
838+
int idx;
839+
840+
if (!bitmap)
841+
return 0;
842+
843+
idx = bitmap_position(bitmap_git, oid);
844+
return idx >= 0 && bitmap_get(bitmap, idx);
845+
}
846+
835847
void traverse_bitmap_commit_list(struct bitmap_index *bitmap_git,
836848
show_reachable_fn show_reachable)
837849
{

pack-bitmap.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33

44
#include "ewah/ewok.h"
55
#include "khash.h"
6+
#include "pack.h"
67
#include "pack-objects.h"
78

89
struct commit;
@@ -53,6 +54,8 @@ int reuse_partial_packfile_from_bitmap(struct bitmap_index *,
5354
int rebuild_existing_bitmaps(struct bitmap_index *, struct packing_data *mapping,
5455
kh_oid_map_t *reused_bitmaps, int show_progress);
5556
void free_bitmap_index(struct bitmap_index *);
57+
int bitmap_walk_contains(struct bitmap_index *,
58+
struct bitmap *bitmap, const struct object_id *oid);
5659

5760
/*
5861
* After a traversal has been performed by prepare_bitmap_walk(), this can be

0 commit comments

Comments
 (0)