@@ -673,6 +673,63 @@ test_expect_success 'bundle progress with --no-quiet' '
grep "%" err
'
+test_expect_success 'create bundle with duplicate refnames' '
+ git bundle create out.bdl "main" "main" &&
+
+ git bundle list-heads out.bdl |
+ make_user_friendly_and_stable_output >actual &&
+ cat >expect <<-\EOF &&
+ <COMMIT-P> refs/heads/main
+ EOF
+ test_cmp expect actual
+'
+
+# This exhibits a bug, since the same refname is now added to the bundle twice.
+test_expect_success 'create bundle with duplicate refnames and --all' '
+ git bundle create out.bdl --all "main" "main" &&
+
+ git bundle list-heads out.bdl |
+ make_user_friendly_and_stable_output >actual &&
+ cat >expect <<-\EOF &&
+ <COMMIT-P> refs/heads/main
+ <COMMIT-N> refs/heads/release
+ <COMMIT-D> refs/heads/topic/1
+ <COMMIT-H> refs/heads/topic/2
+ <COMMIT-D> refs/pull/1/head
+ <COMMIT-G> refs/pull/2/head
+ <TAG-1> refs/tags/v1
+ <TAG-2> refs/tags/v2
+ <TAG-3> refs/tags/v3
+ <COMMIT-P> HEAD
+ <COMMIT-P> refs/heads/main
+ EOF
+ test_cmp expect actual
+'
+
+test_expect_success 'create bundle with duplicate exlusion refnames' '
+ git bundle create out.bdl "main" "main^!" &&
+
+ git bundle list-heads out.bdl |
+ make_user_friendly_and_stable_output >actual &&
+ cat >expect <<-\EOF &&
+ <COMMIT-P> refs/heads/main
+ EOF
+ test_cmp expect actual
+'
+
+# This exhibits a bug, since the same refname is now added to the bundle twice.
+test_expect_success 'create bundle with duplicate refname short-form' '
+ git bundle create out.bdl "main" "main" "refs/heads/main" "refs/heads/main" &&
+
+ git bundle list-heads out.bdl |
+ make_user_friendly_and_stable_output >actual &&
+ cat >expect <<-\EOF &&
+ <COMMIT-P> refs/heads/main
+ <COMMIT-P> refs/heads/main
+ EOF
+ test_cmp expect actual
+'
+
test_expect_success 'read bundle over stdin' '
git bundle create some.bundle HEAD &&
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> --- t/t6020-bundle-misc.sh | 57 ++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 57 insertions(+)