Skip to content

Commit 6663ae0

Browse files
peffgitster
authored andcommitted
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 <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent 4eb707e commit 6663ae0

File tree

5 files changed

+32
-6
lines changed

5 files changed

+32
-6
lines changed

builtin/pack-objects.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3040,7 +3040,7 @@ static int pack_options_allow_reuse(void)
30403040

30413041
static int get_object_list_from_bitmap(struct rev_info *revs)
30423042
{
3043-
if (!(bitmap_git = prepare_bitmap_walk(revs)))
3043+
if (!(bitmap_git = prepare_bitmap_walk(revs, NULL)))
30443044
return -1;
30453045

30463046
if (pack_options_allow_reuse() &&

builtin/rev-list.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -407,7 +407,7 @@ static int try_bitmap_count(struct rev_info *revs)
407407
*/
408408
max_count = revs->max_count;
409409

410-
bitmap_git = prepare_bitmap_walk(revs);
410+
bitmap_git = prepare_bitmap_walk(revs, NULL);
411411
if (!bitmap_git)
412412
return -1;
413413

@@ -434,7 +434,7 @@ static int try_bitmap_traversal(struct rev_info *revs)
434434
if (revs->max_count >= 0)
435435
return -1;
436436

437-
bitmap_git = prepare_bitmap_walk(revs);
437+
bitmap_git = prepare_bitmap_walk(revs, NULL);
438438
if (!bitmap_git)
439439
return -1;
440440

pack-bitmap.c

Lines changed: 25 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212
#include "packfile.h"
1313
#include "repository.h"
1414
#include "object-store.h"
15+
#include "list-objects-filter-options.h"
1516

1617
/*
1718
* 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,
711712
return 0;
712713
}
713714

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)
715734
{
716735
unsigned int i;
717736

@@ -731,6 +750,9 @@ struct bitmap_index *prepare_bitmap_walk(struct rev_info *revs)
731750
if (revs->prune)
732751
return NULL;
733752

753+
if (!can_filter_bitmap(filter))
754+
return NULL;
755+
734756
/* try to open a bitmapped pack, but don't parse it yet
735757
* because we may not need to use it */
736758
bitmap_git = xcalloc(1, sizeof(*bitmap_git));
@@ -800,6 +822,8 @@ struct bitmap_index *prepare_bitmap_walk(struct rev_info *revs)
800822
if (haves_bitmap)
801823
bitmap_and_not(wants_bitmap, haves_bitmap);
802824

825+
filter_bitmap(bitmap_git, wants, wants_bitmap, filter);
826+
803827
bitmap_git->result = wants_bitmap;
804828
bitmap_git->haves = haves_bitmap;
805829

pack-bitmap.h

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88
struct commit;
99
struct repository;
1010
struct rev_info;
11+
struct list_objects_filter_options;
1112

1213
static const char BITMAP_IDX_SIGNATURE[] = {'B', 'I', 'T', 'M'};
1314

@@ -47,7 +48,8 @@ void traverse_bitmap_commit_list(struct bitmap_index *,
4748
struct rev_info *revs,
4849
show_reachable_fn show_reachable);
4950
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);
5153
int reuse_partial_packfile_from_bitmap(struct bitmap_index *,
5254
struct packed_git **packfile,
5355
uint32_t *entries, off_t *up_to);

reachable.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -223,7 +223,7 @@ void mark_reachable_objects(struct rev_info *revs, int mark_reflog,
223223
cp.progress = progress;
224224
cp.count = 0;
225225

226-
bitmap_git = prepare_bitmap_walk(revs);
226+
bitmap_git = prepare_bitmap_walk(revs, NULL);
227227
if (bitmap_git) {
228228
traverse_bitmap_commit_list(bitmap_git, revs, mark_object_seen);
229229
free_bitmap_index(bitmap_git);

0 commit comments

Comments
 (0)