Skip to content

Commit 09d86e0

Browse files
KarthikNayakgitster
authored andcommitted
t6020: test for duplicate refnames in bundle creation
The commit b2a6d1c (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 <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent 485f5f8 commit 09d86e0

File tree

1 file changed

+57
-0
lines changed

1 file changed

+57
-0
lines changed

t/t6020-bundle-misc.sh

Lines changed: 57 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -673,6 +673,63 @@ test_expect_success 'bundle progress with --no-quiet' '
673673
grep "%" err
674674
'
675675

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+
676733
test_expect_success 'read bundle over stdin' '
677734
git bundle create some.bundle HEAD &&
678735

0 commit comments

Comments
 (0)