use strpbrk(3) to search for characters from a given set
[git/debian.git] / t / t5536-fetch-conflicts.sh
blob91f28c2f783df7391d22bd893e2488e56658515b
1 #!/bin/sh
3 test_description='fetch handles conflicting refspecs correctly'
5 . ./test-lib.sh
7 D=$(pwd)
9 setup_repository () {
10 git init "$1" && (
11 cd "$1" &&
12 git config remote.origin.url "$D" &&
13 shift &&
14 for refspec in "$@"
16 git config --add remote.origin.fetch "$refspec"
17 done
21 test_expect_success 'setup' '
22 git commit --allow-empty -m "Initial" &&
23 git branch branch1 &&
24 git tag tag1 &&
25 git commit --allow-empty -m "First" &&
26 git branch branch2 &&
27 git tag tag2
30 test_expect_success 'fetch with no conflict' '
31 setup_repository ok "+refs/heads/*:refs/remotes/origin/*" && (
32 cd ok &&
33 git fetch 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" && (
41 cd ccc &&
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" && (
51 cd dcc &&
52 git fetch origin
56 test_expect_success 'fetch conflict: arg overrides config' '
57 setup_repository aoc \
58 "+refs/heads/*:refs/remotes/origin/*" && (
59 cd aoc &&
60 git fetch origin refs/heads/branch2:refs/remotes/origin/branch1
64 test_expect_success 'fetch conflict: arg vs. arg' '
65 setup_repository caa && (
66 cd 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/*" && (
77 cd xaa &&
78 git fetch 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
86 test_done