Skip to content

Commit e03f928

Browse files
peffgitster
authored andcommitted
rev-list: fallback to non-bitmap traversal when filtering
The "--use-bitmap-index" option is usually aspirational: if we have bitmaps and the request can be fulfilled more quickly using them we'll do so, but otherwise fall back to a non-bitmap traversal. The exception is object filtering, which explicitly dies if the two options are combined. Let's convert this to the usual fallback behavior. This is a minor convenience for now (since the caller can easily know that --filter and --use-bitmap-index don't combine), but will become much more useful as we start to support _some_ filters with bitmaps, but not others. The test infrastructure here is bigger than necessary for checking this one small feature. But it will serve as the basis for more filtering bitmap tests in future patches. Signed-off-by: Jeff King <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent acac50d commit e03f928

File tree

2 files changed

+26
-2
lines changed

2 files changed

+26
-2
lines changed

builtin/rev-list.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -521,8 +521,8 @@ int cmd_rev_list(int argc, const char **argv, const char *prefix)
521521
if (revs.show_notes)
522522
die(_("rev-list does not support display of notes"));
523523

524-
if (filter_options.choice && use_bitmap_index)
525-
die(_("cannot combine --use-bitmap-index with object filtering"));
524+
if (filter_options.choice)
525+
use_bitmap_index = 0;
526526

527527
save_commit_buffer = (revs.verbose_header ||
528528
revs.grep_filter.pattern_list ||

t/t6113-rev-list-bitmap-filters.sh

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
#!/bin/sh
2+
3+
test_description='rev-list combining bitmaps and filters'
4+
. ./test-lib.sh
5+
6+
test_expect_success 'set up bitmapped repo' '
7+
# one commit will have bitmaps, the other will not
8+
test_commit one &&
9+
git repack -adb &&
10+
test_commit two
11+
'
12+
13+
test_expect_success 'filters fallback to non-bitmap traversal' '
14+
# use a path-based filter, since they are inherently incompatible with
15+
# bitmaps (i.e., this test will never get confused by later code to
16+
# combine the features)
17+
filter=$(echo "!one" | git hash-object -w --stdin) &&
18+
git rev-list --objects --filter=sparse:oid=$filter HEAD >expect &&
19+
git rev-list --use-bitmap-index \
20+
--objects --filter=sparse:oid=$filter HEAD >actual &&
21+
test_cmp expect actual
22+
'
23+
24+
test_done

0 commit comments

Comments
 (0)