OSDN Git Service

rev-list: disable --use-bitmap-index when pruning commits
authorJeff King <peff@peff.net>
Wed, 1 Jul 2015 18:42:17 +0000 (14:42 -0400)
committerJunio C Hamano <gitster@pobox.com>
Wed, 1 Jul 2015 19:00:50 +0000 (12:00 -0700)
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>
builtin/rev-list.c
t/t5310-pack-bitmaps.sh

index ff84a82..88eddbd 100644 (file)
@@ -355,7 +355,7 @@ int cmd_rev_list(int argc, const char **argv, const char *prefix)
        if (bisect_list)
                revs.limited = 1;
 
-       if (use_bitmap_index) {
+       if (use_bitmap_index && !revs.prune) {
                if (revs.count && !revs.left_right && !revs.cherry_mark) {
                        uint32_t commit_count;
                        if (!prepare_bitmap_walk(&revs)) {
index f4f02ba..bbb7623 100755 (executable)
@@ -53,6 +53,12 @@ rev_list_tests() {
                test_cmp expect actual
        '
 
+       test_expect_success "counting commits with limiting ($state)" '
+               git rev-list --count HEAD -- 1.t >expect &&
+               git rev-list --use-bitmap-index --count HEAD -- 1.t >actual &&
+               test_cmp expect actual
+       '
+
        test_expect_success "enumerate --objects ($state)" '
                git rev-list --objects --use-bitmap-index HEAD >tmp &&
                cut -d" " -f1 <tmp >tmp2 &&