Skip to content

Commit 16a186f

Browse files
peffttaylorr
authored andcommitted
rev-list: skip bitmap traversal for --left-right
Running: git rev-list --left-right --use-bitmap-index one...two will produce output without any left-right markers, since the bitmap traversal returns only a single set of reachable commits. Instead we should refuse to use bitmaps here and produce the correct output using a traditional traversal. This is probably not the only remaining option that misbehaves with bitmaps, but it's particularly egregious in that it feels like it _could_ work. Doing two separate traversals for the left/right sides and then taking the symmetric set differences should yield the correct answer, but our traversal code doesn't know how to do that. It's not clear if naively doing two separate traversals would always be a performance win. A traditional traversal only needs to walk down to the merge base, but bitmaps always fill out the full reachability set. So depending on your bitmap coverage, we could end up walking old bits of history twice to fill out the same uninteresting bits on both sides. We'd also of course end up with a very large --boundary set, if the user asked for that. So this might or might not be something worth implementing later. But for now, let's make sure we don't produce the wrong answer if somebody tries it. The test covers this, but also the same thing with "--count" (which is what I originally tried in a real-world case). Ironically the try_bitmap_count() code already realizes that "--left-right" won't work there. But that just causes us to fall back to the regular bitmap traversal code, which itself doesn't handle counting (we produce a list of objects rather than a count). Signed-off-by: Jeff King <[email protected]> Signed-off-by: Taylor Blau <[email protected]>
1 parent 23d289d commit 16a186f

File tree

2 files changed

+19
-0
lines changed

2 files changed

+19
-0
lines changed

builtin/rev-list.c

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -485,6 +485,13 @@ static int try_bitmap_traversal(struct rev_info *revs,
485485
if (revs->max_count >= 0)
486486
return -1;
487487

488+
/*
489+
* We can't know which commits were left/right in a single traversal,
490+
* and we don't yet know how to traverse them separately.
491+
*/
492+
if (revs->left_right)
493+
return -1;
494+
488495
bitmap_git = prepare_bitmap_walk(revs, filter_provided_objects);
489496
if (!bitmap_git)
490497
return -1;

t/t5310-pack-bitmaps.sh

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -503,6 +503,18 @@ test_expect_success 'boundary-based traversal is used when requested' '
503503
done
504504
'
505505

506+
test_expect_success 'left-right not confused by bitmap index' '
507+
git rev-list --left-right other...HEAD >expect &&
508+
git rev-list --use-bitmap-index --left-right other...HEAD >actual &&
509+
test_cmp expect actual
510+
'
511+
512+
test_expect_success 'left-right count not confused by bitmap-index' '
513+
git rev-list --left-right --count other...HEAD >expect &&
514+
git rev-list --use-bitmap-index --left-right --count other...HEAD >actual &&
515+
test_cmp expect actual
516+
'
517+
506518
test_bitmap_cases "pack.writeBitmapLookupTable"
507519

508520
test_expect_success 'verify writing bitmap lookup table when enabled' '

0 commit comments

Comments
 (0)