]> git.ipfire.org Git - thirdparty/git.git/commitdiff
pack-bitmap: introduce bitmap_walk_contains()
authorJeff King <peff@peff.net>
Wed, 18 Dec 2019 11:25:39 +0000 (12:25 +0100)
committerJunio C Hamano <gitster@pobox.com>
Thu, 23 Jan 2020 18:51:50 +0000 (10:51 -0800)
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>
pack-bitmap.c
pack-bitmap.h

index ed2befaac6535f25602fca57374d27d058277426..8891797c007cdab6dd02d78fae0bea04d00e6347 100644 (file)
@@ -832,6 +832,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)
 {
index 00de3ec8e41d88b972ea28387930ad4342a2defe..5425767f0fa2c1fc9be8f15321f3efaf95238222 100644 (file)
@@ -3,6 +3,7 @@
 
 #include "ewah/ewok.h"
 #include "khash.h"
+#include "pack.h"
 #include "pack-objects.h"
 
 struct commit;
@@ -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