Skip to content

Commit

Permalink
pack-bitmap: introduce bitmap_walk_contains()
Browse files Browse the repository at this point in the history
We will use this helper function in a following commit to
tell us if an object is packed.

Signed-off-by: Jeff King <peff@peff.net>
Signed-off-by: Christian Couder <chriscool@tuxfamily.org>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
  • Loading branch information
peff authored and gitster committed Oct 23, 2019
1 parent 672c6d6 commit 7b143c1
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 0 deletions.
12 changes: 12 additions & 0 deletions pack-bitmap.c
Expand Up @@ -828,6 +828,18 @@ int reuse_partial_packfile_from_bitmap(struct bitmap_index *bitmap_git,
return 0;
}

int bitmap_walk_contains(struct bitmap_index *bitmap_git,
struct bitmap *bitmap, const struct object_id *oid)
{
int idx;

if (!bitmap)
return 0;

idx = bitmap_position(bitmap_git, oid);
return idx >= 0 && bitmap_get(bitmap, idx);
}

void traverse_bitmap_commit_list(struct bitmap_index *bitmap_git,
show_reachable_fn show_reachable)
{
Expand Down
3 changes: 3 additions & 0 deletions pack-bitmap.h
Expand Up @@ -3,6 +3,7 @@

#include "ewah/ewok.h"
#include "khash.h"
#include "pack.h"
#include "pack-objects.h"

struct commit;
Expand Down Expand Up @@ -53,6 +54,8 @@ int reuse_partial_packfile_from_bitmap(struct bitmap_index *,
int rebuild_existing_bitmaps(struct bitmap_index *, struct packing_data *mapping,
kh_oid_map_t *reused_bitmaps, int show_progress);
void free_bitmap_index(struct bitmap_index *);
int bitmap_walk_contains(struct bitmap_index *,
struct bitmap *bitmap, const struct object_id *oid);

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

0 comments on commit 7b143c1

Please sign in to comment.