3 test_description
='fetch handles conflicting refspecs correctly'
5 TEST_PASSES_SANITIZE_LEAK
=true
13 git config remote.origin.url
"$D" &&
17 git config
--add remote.origin.fetch
"$refspec"
22 test_expect_success
'setup' '
23 git commit --allow-empty -m "Initial" &&
26 git commit --allow-empty -m "First" &&
31 test_expect_success
'fetch with no conflict' '
32 setup_repository ok "+refs/heads/*:refs/remotes/origin/*" && (
38 test_expect_success
'fetch conflict: config vs. config' '
39 setup_repository ccc \
40 "+refs/heads/branch1:refs/remotes/origin/branch1" \
41 "+refs/heads/branch2:refs/remotes/origin/branch1" && (
43 test_must_fail git fetch origin 2>error &&
44 test_grep "fatal: Cannot fetch both refs/heads/branch1 and refs/heads/branch2 to refs/remotes/origin/branch1" error
48 test_expect_success
'fetch duplicate: config vs. config' '
49 setup_repository dcc \
50 "+refs/heads/*:refs/remotes/origin/*" \
51 "+refs/heads/branch1:refs/remotes/origin/branch1" && (
57 test_expect_success
'fetch conflict: arg overrides config' '
58 setup_repository aoc \
59 "+refs/heads/*:refs/remotes/origin/*" && (
61 git fetch origin refs/heads/branch2:refs/remotes/origin/branch1
65 test_expect_success
'fetch conflict: arg vs. arg' '
66 setup_repository caa && (
68 test_must_fail git fetch origin \
69 refs/heads/*:refs/remotes/origin/* \
70 refs/heads/branch2:refs/remotes/origin/branch1 2>error &&
71 test_grep "fatal: Cannot fetch both refs/heads/branch1 and refs/heads/branch2 to refs/remotes/origin/branch1" error
75 test_expect_success
'fetch conflict: criss-cross args' '
76 setup_repository xaa \
77 "+refs/heads/*:refs/remotes/origin/*" && (
80 refs/heads/branch1:refs/remotes/origin/branch2 \
81 refs/heads/branch2:refs/remotes/origin/branch1 2>error &&
82 test_grep "warning: refs/remotes/origin/branch1 usually tracks refs/heads/branch1, not refs/heads/branch2" error &&
83 test_grep "warning: refs/remotes/origin/branch2 usually tracks refs/heads/branch2, not refs/heads/branch1" error