@matheusbsbs / matheus-bagliano / commits / e03f928e2a
Fork 0

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 <peff@peff.net> Signed-off-by: Junio C Hamano <gitster@pobox.com>

Jeff King committed Feb 12, 2020 at 21:17 UTC e03f928e2ab92e47467d48520a73a19582dff286
2 files changed +26 -2
builtin/rev-list.c
+2 -2
@@ -521,8 +521,8 @@ int cmd_rev_list(int argc, const char **argv, const char *prefix)
521 if (revs.show_notes)
522 die(_("rev-list does not support display of notes"));
523
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;
526
527 save_commit_buffer = (revs.verbose_header ||
528 revs.grep_filter.pattern_list ||
t/t6113-rev-list-bitmap-filters.sh new
+24
@@ -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