Git fork

t6020: test for duplicate refnames in bundle creation

The commit b2a6d1c686 (bundle: allow the same ref to be given more than
once, 2009-01-17) added functionality to detect and remove duplicate
refnames from being added during bundle creation. This ensured that
clones created from such bundles wouldn't barf about duplicate refnames.

The following commit will add some optimizations to make this check
faster, but before doing that, it would be optimal to add tests to
capture the current behavior.

Add tests to capture duplicate refnames provided by the user during
bundle creation. This can be a combination of:

- refnames directly provided by the user.
- refname duplicate by using the '--all' flag alongside manual
references being provided.
- exclusion criteria provided via a refname "main^!".
- short forms of refnames provided, "main" vs "refs/heads/main".

Note that currently duplicates due to usage of short and long forms goes
undetected. This should be fixed with the optimizations made in the next
commit.

Signed-off-by: Karthik Nayak <karthik.188@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>

authored by

Karthik Nayak and committed by
Junio C Hamano
09d86e0b 485f5f86

+57
+57
t/t6020-bundle-misc.sh
··· 673 673 grep "%" err 674 674 ' 675 675 676 + test_expect_success 'create bundle with duplicate refnames' ' 677 + git bundle create out.bdl "main" "main" && 678 + 679 + git bundle list-heads out.bdl | 680 + make_user_friendly_and_stable_output >actual && 681 + cat >expect <<-\EOF && 682 + <COMMIT-P> refs/heads/main 683 + EOF 684 + test_cmp expect actual 685 + ' 686 + 687 + # This exhibits a bug, since the same refname is now added to the bundle twice. 688 + test_expect_success 'create bundle with duplicate refnames and --all' ' 689 + git bundle create out.bdl --all "main" "main" && 690 + 691 + git bundle list-heads out.bdl | 692 + make_user_friendly_and_stable_output >actual && 693 + cat >expect <<-\EOF && 694 + <COMMIT-P> refs/heads/main 695 + <COMMIT-N> refs/heads/release 696 + <COMMIT-D> refs/heads/topic/1 697 + <COMMIT-H> refs/heads/topic/2 698 + <COMMIT-D> refs/pull/1/head 699 + <COMMIT-G> refs/pull/2/head 700 + <TAG-1> refs/tags/v1 701 + <TAG-2> refs/tags/v2 702 + <TAG-3> refs/tags/v3 703 + <COMMIT-P> HEAD 704 + <COMMIT-P> refs/heads/main 705 + EOF 706 + test_cmp expect actual 707 + ' 708 + 709 + test_expect_success 'create bundle with duplicate exlusion refnames' ' 710 + git bundle create out.bdl "main" "main^!" && 711 + 712 + git bundle list-heads out.bdl | 713 + make_user_friendly_and_stable_output >actual && 714 + cat >expect <<-\EOF && 715 + <COMMIT-P> refs/heads/main 716 + EOF 717 + test_cmp expect actual 718 + ' 719 + 720 + # This exhibits a bug, since the same refname is now added to the bundle twice. 721 + test_expect_success 'create bundle with duplicate refname short-form' ' 722 + git bundle create out.bdl "main" "main" "refs/heads/main" "refs/heads/main" && 723 + 724 + git bundle list-heads out.bdl | 725 + make_user_friendly_and_stable_output >actual && 726 + cat >expect <<-\EOF && 727 + <COMMIT-P> refs/heads/main 728 + <COMMIT-P> refs/heads/main 729 + EOF 730 + test_cmp expect actual 731 + ' 732 + 676 733 test_expect_success 'read bundle over stdin' ' 677 734 git bundle create some.bundle HEAD && 678 735