t6600: add tests for duplicate tips in tips_reachable_from_bases()

When multiple refs point to the same commit, the reachability check must handle them correctly. Add three tests: - duplicate tips, all reachable - duplicate tips, none reachable - duplicate tips at the minimum generation (exercises the early-termination advancement logic) Suggested-by: Derrick Stolee <stolee@gmail.com> Signed-off-by: Kristofer Karlsson <krka@spotify.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>

Kristofer Karlsson committed May 16, 2026 at 15:59 UTC a30f132bcb62bc44053b1dba0940c2d4041c797a
1 file changed +45
t/t6600-test-reach.sh
+45
@@ -612,6 +612,51 @@ test_expect_success 'for-each-ref merged:none' '
612 --format="%(refname)" --stdin
613 '
614
615 +test_expect_success 'for-each-ref merged:duplicate, all reachable' '
616 + git branch dup-a commit-3-3 &&
617 + git branch dup-b commit-3-3 &&
618 + cat >input <<-\EOF &&
619 + refs/heads/commit-1-1
620 + refs/heads/dup-a
621 + refs/heads/dup-b
622 + EOF
623 + cat >expect <<-\EOF &&
624 + refs/heads/commit-1-1
625 + refs/heads/dup-a
626 + refs/heads/dup-b
627 + EOF
628 + run_all_modes git for-each-ref --merged=commit-5-5 \
629 + --format="%(refname)" --stdin
630 +'
631 +
632 +test_expect_success 'for-each-ref merged:duplicate, none reachable' '
633 + cat >input <<-\EOF &&
634 + refs/heads/dup-a
635 + refs/heads/dup-b
636 + refs/heads/commit-9-9
637 + EOF
638 + >expect &&
639 + run_all_modes git for-each-ref --merged=commit-2-2 \
640 + --format="%(refname)" --stdin
641 +'
642 +
643 +test_expect_success 'for-each-ref merged:duplicate at min generation' '
644 + git branch dup-c commit-1-1 &&
645 + git branch dup-d commit-1-1 &&
646 + cat >input <<-\EOF &&
647 + refs/heads/dup-c
648 + refs/heads/dup-d
649 + refs/heads/commit-5-5
650 + EOF
651 + cat >expect <<-\EOF &&
652 + refs/heads/commit-5-5
653 + refs/heads/dup-c
654 + refs/heads/dup-d
655 + EOF
656 + run_all_modes git for-each-ref --merged=commit-5-5 \
657 + --format="%(refname)" --stdin
658 +'
659 +
660 # For get_branch_base_for_tip, we only care about
661 # first-parent history. Here is the test graph with
662 # second parents removed: