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
@@ -837,4 +837,49 @@ test_expect_success 'rev-list --maximal-only (range)' '
837 --first-parent --exclude-first-parent-only
838 '
839
840 +test_expect_success 'rev-list --maximal-only matches merge-base --independent' '
841 + # Mix of independent and dependent
842 + git merge-base --independent \
843 + refs/heads/commit-5-2 \
844 + refs/heads/commit-3-2 \
845 + refs/heads/commit-2-5 >expect &&
846 + sort expect >expect.sorted &&
847 + git rev-list --maximal-only \
848 + refs/heads/commit-5-2 \
849 + refs/heads/commit-3-2 \
850 + refs/heads/commit-2-5 >actual &&
851 + sort actual >actual.sorted &&
852 + test_cmp expect.sorted actual.sorted &&
853 +
854 + # All independent commits.
855 + git merge-base --independent \
856 + refs/heads/commit-5-2 \
857 + refs/heads/commit-4-3 \
858 + refs/heads/commit-3-4 \
859 + refs/heads/commit-2-5 >expect &&
860 + sort expect >expect.sorted &&
861 + git rev-list --maximal-only \
862 + refs/heads/commit-5-2 \
863 + refs/heads/commit-4-3 \
864 + refs/heads/commit-3-4 \
865 + refs/heads/commit-2-5 >actual &&
866 + sort actual >actual.sorted &&
867 + test_cmp expect.sorted actual.sorted &&
868 +
869 + # Only one independent.
870 + git merge-base --independent \
871 + refs/heads/commit-1-1 \
872 + refs/heads/commit-4-2 \
873 + refs/heads/commit-4-4 \
874 + refs/heads/commit-8-4 >expect &&
875 + sort expect >expect.sorted &&
876 + git rev-list --maximal-only \
877 + refs/heads/commit-1-1 \
878 + refs/heads/commit-4-2 \
879 + refs/heads/commit-4-4 \
880 + refs/heads/commit-8-4 >actual &&
881 + sort actual >actual.sorted &&
882 + test_cmp expect.sorted actual.sorted
883 +'
884 +
885 test_done