3 test_description='fetch handles conflicting refspecs correctly'
12 git config remote.origin.url "$D" &&
16 git config --add remote.origin.fetch "$refspec"
21 test_expect_success 'setup' '
22 git commit --allow-empty -m "Initial" &&
25 git commit --allow-empty -m "First" &&
30 test_expect_success 'fetch with no conflict' '
31 setup_repository ok "+refs/heads/*:refs/remotes/origin/*" && (
37 test_expect_success 'fetch conflict: config vs. config' '
38 setup_repository ccc \
39 "+refs/heads/branch1:refs/remotes/origin/branch1" \
40 "+refs/heads/branch2:refs/remotes/origin/branch1" && (
42 test_must_fail git fetch origin 2>error &&
43 test_i18ngrep "fatal: Cannot fetch both refs/heads/branch1 and refs/heads/branch2 to refs/remotes/origin/branch1" error
47 test_expect_success 'fetch duplicate: config vs. config' '
48 setup_repository dcc \
49 "+refs/heads/*:refs/remotes/origin/*" \
50 "+refs/heads/branch1:refs/remotes/origin/branch1" && (
56 test_expect_success 'fetch conflict: arg overrides config' '
57 setup_repository aoc \
58 "+refs/heads/*:refs/remotes/origin/*" && (
60 git fetch origin refs/heads/branch2:refs/remotes/origin/branch1
64 test_expect_success 'fetch conflict: arg vs. arg' '
65 setup_repository caa && (
67 test_must_fail git fetch origin \
68 refs/heads/*:refs/remotes/origin/* \
69 refs/heads/branch2:refs/remotes/origin/branch1 2>error &&
70 test_i18ngrep "fatal: Cannot fetch both refs/heads/branch1 and refs/heads/branch2 to refs/remotes/origin/branch1" error
74 test_expect_success 'fetch conflict: criss-cross args' '
75 setup_repository xaa \
76 "+refs/heads/*:refs/remotes/origin/*" && (
79 refs/heads/branch1:refs/remotes/origin/branch2 \
80 refs/heads/branch2:refs/remotes/origin/branch1 2>error &&
81 test_i18ngrep "warning: refs/remotes/origin/branch1 usually tracks refs/heads/branch1, not refs/heads/branch2" error &&
82 test_i18ngrep "warning: refs/remotes/origin/branch2 usually tracks refs/heads/branch2, not refs/heads/branch1" error