Skip to content

Commit c8a70d3

Browse files
peffgitster
authored andcommitted
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 <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent 282616c commit c8a70d3

File tree

2 files changed

+7
-1
lines changed

2 files changed

+7
-1
lines changed

builtin/rev-list.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -355,7 +355,7 @@ int cmd_rev_list(int argc, const char **argv, const char *prefix)
355355
if (bisect_list)
356356
revs.limited = 1;
357357

358-
if (use_bitmap_index) {
358+
if (use_bitmap_index && !revs.prune) {
359359
if (revs.count && !revs.left_right && !revs.cherry_mark) {
360360
uint32_t commit_count;
361361
if (!prepare_bitmap_walk(&revs)) {

t/t5310-pack-bitmaps.sh

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,12 @@ rev_list_tests() {
5353
test_cmp expect actual
5454
'
5555

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+
5662
test_expect_success "enumerate --objects ($state)" '
5763
git rev-list --objects --use-bitmap-index HEAD >tmp &&
5864
cut -d" " -f1 <tmp >tmp2 &&

0 commit comments

Comments
 (0)