summaryrefslogtreecommitdiff
path: root/pack-bitmap.c
diff options
context:
space:
mode:
authorJeff King <peff@peff.net>2020-02-14 18:22:29 (GMT)
committerJunio C Hamano <gitster@pobox.com>2020-02-14 18:46:22 (GMT)
commit6663ae0a0818aba5d4de289b1a37e1961ad6c367 (patch)
tree408ed5d15e418684930628fcd4e5346cdd4b55b7 /pack-bitmap.c
parent4eb707ebd681eb85306071db33ed70186d1642ac (diff)
downloadgit-6663ae0a0818aba5d4de289b1a37e1961ad6c367.zip
git-6663ae0a0818aba5d4de289b1a37e1961ad6c367.tar.gz
git-6663ae0a0818aba5d4de289b1a37e1961ad6c367.tar.bz2
pack-bitmap: basic noop bitmap filter infrastructure
Currently you can't use object filters with bitmaps, but we plan to support at least some filters with bitmaps. Let's introduce some infrastructure that will help us do that: - prepare_bitmap_walk() now accepts a list_objects_filter_options parameter (which can be NULL for no filtering; all the current callers pass this) - we'll bail early if the filter is incompatible with bitmaps (just as we would if there were no bitmaps at all). Currently all filters are incompatible. - we'll filter the resulting bitmap; since there are no supported filters yet, this is always a noop. There should be no behavior change yet, but we'll support some actual filters in a future patch. Signed-off-by: Jeff King <peff@peff.net> Signed-off-by: Junio C Hamano <gitster@pobox.com>
Diffstat (limited to 'pack-bitmap.c')
-rw-r--r--pack-bitmap.c26
1 files changed, 25 insertions, 1 deletions
diff --git a/pack-bitmap.c b/pack-bitmap.c
index 2fbc748..48c8694 100644
--- a/pack-bitmap.c
+++ b/pack-bitmap.c
@@ -12,6 +12,7 @@
#include "packfile.h"
#include "repository.h"
#include "object-store.h"
+#include "list-objects-filter-options.h"
/*
* An entry on the bitmap index, representing the bitmap for a given
@@ -711,7 +712,25 @@ static int in_bitmapped_pack(struct bitmap_index *bitmap_git,
return 0;
}
-struct bitmap_index *prepare_bitmap_walk(struct rev_info *revs)
+static int filter_bitmap(struct bitmap_index *bitmap_git,
+ struct object_list *tip_objects,
+ struct bitmap *to_filter,
+ struct list_objects_filter_options *filter)
+{
+ if (!filter || filter->choice == LOFC_DISABLED)
+ return 0;
+
+ /* filter choice not handled */
+ return -1;
+}
+
+static int can_filter_bitmap(struct list_objects_filter_options *filter)
+{
+ return !filter_bitmap(NULL, NULL, NULL, filter);
+}
+
+struct bitmap_index *prepare_bitmap_walk(struct rev_info *revs,
+ struct list_objects_filter_options *filter)
{
unsigned int i;
@@ -731,6 +750,9 @@ struct bitmap_index *prepare_bitmap_walk(struct rev_info *revs)
if (revs->prune)
return NULL;
+ if (!can_filter_bitmap(filter))
+ return NULL;
+
/* try to open a bitmapped pack, but don't parse it yet
* because we may not need to use it */
bitmap_git = xcalloc(1, sizeof(*bitmap_git));
@@ -800,6 +822,8 @@ struct bitmap_index *prepare_bitmap_walk(struct rev_info *revs)
if (haves_bitmap)
bitmap_and_not(wants_bitmap, haves_bitmap);
+ filter_bitmap(bitmap_git, wants, wants_bitmap, filter);
+
bitmap_git->result = wants_bitmap;
bitmap_git->haves = haves_bitmap;