rev-list: disable --use-bitmap-index when pruning commits
The reachability bitmaps do not have enough information to tell us which commits might have changed path "foo", so the current code produces wrong answers for: git rev-list --use-bitmap-index --count HEAD -- foo (it silently ignores the "foo" limiter). Instead, we should fall back to doing a normal traversal (it is OK to fall back rather than complain, because --use-bitmap-index is a pure optimization, and might not kick in for other reasons, such as there being no bitmaps in the repository). Signed-off-by: Jeff King <peff@peff.net> Signed-off-by: Junio C Hamano <gitster@pobox.com>
Jeff King committed
Jul 1, 2015 at 14:42 UTC
c8a70d35090c490ce0e9f1354ef372b2887bea28
2 files changed
+7
-1
builtin/rev-list.c
+1
-1
@@ -355,7 +355,7 @@ int cmd_rev_list(int argc, const char **argv, const char *prefix)
355
if (bisect_list)
356
revs.limited = 1;
357
358
- if (use_bitmap_index) {
358
+ if (use_bitmap_index && !revs.prune) {
359
if (revs.count && !revs.left_right && !revs.cherry_mark) {
360
uint32_t commit_count;
361
if (!prepare_bitmap_walk(&revs)) {
t/t5310-pack-bitmaps.sh
+6
@@ -53,6 +53,12 @@ rev_list_tests() {
53
test_cmp expect actual
54
'
55
56
+ test_expect_success "counting commits with limiting ($state)" '
57
+ git rev-list --count HEAD -- 1.t >expect &&
58
+ git rev-list --use-bitmap-index --count HEAD -- 1.t >actual &&
59
+ test_cmp expect actual
60
+ '
61
+
62
test_expect_success "enumerate --objects ($state)" '
63
git rev-list --objects --use-bitmap-index HEAD >tmp &&
64
cut -d" " -f1 <tmp >tmp2 &&