t6600: test --maximal-only and --independent
Add a test that verifies the 'git rev-list --maximal-only' option produces the same set of commits as 'git merge-base --independent'. This equivalence was noted when the feature was first created, but we are about to update the implementation to use a common algorithm in this case where the user intention is identical. Signed-off-by: Derrick Stolee <stolee@gmail.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
Derrick Stolee committed
Apr 6, 2026 at 13:27 UTC
295fb82264cc8be565a5da8259b103cbc6a41728
1 file changed
+45
t/t6600-test-reach.sh
+45
index 2613075894..dc0421ed2f 100755
--- a/t/t6600-test-reach.sh
+++ b/t/t6600-test-reach.sh
@@ -837,4 +837,49 @@ test_expect_success 'rev-list --maximal-only (range)' '
--first-parent --exclude-first-parent-only
'
+test_expect_success 'rev-list --maximal-only matches merge-base --independent' '
+ # Mix of independent and dependent
+ git merge-base --independent \
+ refs/heads/commit-5-2 \
+ refs/heads/commit-3-2 \
+ refs/heads/commit-2-5 >expect &&
+ sort expect >expect.sorted &&
+ git rev-list --maximal-only \
+ refs/heads/commit-5-2 \
+ refs/heads/commit-3-2 \
+ refs/heads/commit-2-5 >actual &&
+ sort actual >actual.sorted &&
+ test_cmp expect.sorted actual.sorted &&
+
+ # All independent commits.
+ git merge-base --independent \
+ refs/heads/commit-5-2 \
+ refs/heads/commit-4-3 \
+ refs/heads/commit-3-4 \
+ refs/heads/commit-2-5 >expect &&
+ sort expect >expect.sorted &&
+ git rev-list --maximal-only \
+ refs/heads/commit-5-2 \
+ refs/heads/commit-4-3 \
+ refs/heads/commit-3-4 \
+ refs/heads/commit-2-5 >actual &&
+ sort actual >actual.sorted &&
+ test_cmp expect.sorted actual.sorted &&
+
+ # Only one independent.
+ git merge-base --independent \
+ refs/heads/commit-1-1 \
+ refs/heads/commit-4-2 \
+ refs/heads/commit-4-4 \
+ refs/heads/commit-8-4 >expect &&
+ sort expect >expect.sorted &&
+ git rev-list --maximal-only \
+ refs/heads/commit-1-1 \
+ refs/heads/commit-4-2 \
+ refs/heads/commit-4-4 \
+ refs/heads/commit-8-4 >actual &&
+ sort actual >actual.sorted &&
+ test_cmp expect.sorted actual.sorted
+'
+
test_done