@matheusbsbs / matheus-bagliano / commits / 6663ae0a08
Fork 0

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>

Jeff King committed Feb 14, 2020 at 13:22 UTC 6663ae0a0818aba5d4de289b1a37e1961ad6c367
5 files changed +32 -6
builtin/pack-objects.c
+1 -1
@@ -3040,7 +3040,7 @@ static int pack_options_allow_reuse(void)
3040
3041 static int get_object_list_from_bitmap(struct rev_info *revs)
3042 {
3043 - if (!(bitmap_git = prepare_bitmap_walk(revs)))
3043 + if (!(bitmap_git = prepare_bitmap_walk(revs, NULL)))
3044 return -1;
3045
3046 if (pack_options_allow_reuse() &&
builtin/rev-list.c
+2 -2
@@ -407,7 +407,7 @@ static int try_bitmap_count(struct rev_info *revs)
407 */
408 max_count = revs->max_count;
409
410 - bitmap_git = prepare_bitmap_walk(revs);
410 + bitmap_git = prepare_bitmap_walk(revs, NULL);
411 if (!bitmap_git)
412 return -1;
413
@@ -434,7 +434,7 @@ static int try_bitmap_traversal(struct rev_info *revs)
434 if (revs->max_count >= 0)
435 return -1;
436
437 - bitmap_git = prepare_bitmap_walk(revs);
437 + bitmap_git = prepare_bitmap_walk(revs, NULL);
438 if (!bitmap_git)
439 return -1;
440
pack-bitmap.c
+25 -1
@@ -12,6 +12,7 @@
12 #include "packfile.h"
13 #include "repository.h"
14 #include "object-store.h"
15 +#include "list-objects-filter-options.h"
16
17 /*
18 * 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,
712 return 0;
713 }
714
714 -struct bitmap_index *prepare_bitmap_walk(struct rev_info *revs)
715 +static int filter_bitmap(struct bitmap_index *bitmap_git,
716 + struct object_list *tip_objects,
717 + struct bitmap *to_filter,
718 + struct list_objects_filter_options *filter)
719 +{
720 + if (!filter || filter->choice == LOFC_DISABLED)
721 + return 0;
722 +
723 + /* filter choice not handled */
724 + return -1;
725 +}
726 +
727 +static int can_filter_bitmap(struct list_objects_filter_options *filter)
728 +{
729 + return !filter_bitmap(NULL, NULL, NULL, filter);
730 +}
731 +
732 +struct bitmap_index *prepare_bitmap_walk(struct rev_info *revs,
733 + struct list_objects_filter_options *filter)
734 {
735 unsigned int i;
736
@@ -731,6 +750,9 @@ struct bitmap_index *prepare_bitmap_walk(struct rev_info *revs)
750 if (revs->prune)
751 return NULL;
752
753 + if (!can_filter_bitmap(filter))
754 + return NULL;
755 +
756 /* try to open a bitmapped pack, but don't parse it yet
757 * because we may not need to use it */
758 bitmap_git = xcalloc(1, sizeof(*bitmap_git));
@@ -800,6 +822,8 @@ struct bitmap_index *prepare_bitmap_walk(struct rev_info *revs)
822 if (haves_bitmap)
823 bitmap_and_not(wants_bitmap, haves_bitmap);
824
825 + filter_bitmap(bitmap_git, wants, wants_bitmap, filter);
826 +
827 bitmap_git->result = wants_bitmap;
828 bitmap_git->haves = haves_bitmap;
829
pack-bitmap.h
+3 -1
@@ -8,6 +8,7 @@
8 struct commit;
9 struct repository;
10 struct rev_info;
11 +struct list_objects_filter_options;
12
13 static const char BITMAP_IDX_SIGNATURE[] = {'B', 'I', 'T', 'M'};
14
@@ -47,7 +48,8 @@ void traverse_bitmap_commit_list(struct bitmap_index *,
48 struct rev_info *revs,
49 show_reachable_fn show_reachable);
50 void test_bitmap_walk(struct rev_info *revs);
50 -struct bitmap_index *prepare_bitmap_walk(struct rev_info *revs);
51 +struct bitmap_index *prepare_bitmap_walk(struct rev_info *revs,
52 + struct list_objects_filter_options *filter);
53 int reuse_partial_packfile_from_bitmap(struct bitmap_index *,
54 struct packed_git **packfile,
55 uint32_t *entries, off_t *up_to);
reachable.c
+1 -1
@@ -223,7 +223,7 @@ void mark_reachable_objects(struct rev_info *revs, int mark_reflog,
223 cp.progress = progress;
224 cp.count = 0;
225
226 - bitmap_git = prepare_bitmap_walk(revs);
226 + bitmap_git = prepare_bitmap_walk(revs, NULL);
227 if (bitmap_git) {
228 traverse_bitmap_commit_list(bitmap_git, revs, mark_object_seen);
229 free_bitmap_index(bitmap_git);