setup_revisions(): take pathspec from command line and --stdin correctly
[git.git] / t / t5514-fetch-multiple.sh
blobb73733219d62cabf02c59ed0bf08caec1158faef
1 #!/bin/sh
3 test_description='fetch --all works correctly'
5 . ./test-lib.sh
7 setup_repository () {
8 mkdir "$1" && (
9 cd "$1" &&
10 git init &&
11 >file &&
12 git add file &&
13 test_tick &&
14 git commit -m "Initial" &&
15 git checkout -b side &&
16 >elif &&
17 git add elif &&
18 test_tick &&
19 git commit -m "Second" &&
20 git checkout master
24 test_expect_success setup '
25 setup_repository one &&
26 setup_repository two &&
28 cd two && git branch another
29 ) &&
30 git clone --mirror two three
31 git clone one test
34 cat > test/expect << EOF
35 one/master
36 one/side
37 origin/HEAD -> origin/master
38 origin/master
39 origin/side
40 three/another
41 three/master
42 three/side
43 two/another
44 two/master
45 two/side
46 EOF
48 test_expect_success 'git fetch --all' '
49 (cd test &&
50 git remote add one ../one &&
51 git remote add two ../two &&
52 git remote add three ../three &&
53 git fetch --all &&
54 git branch -r > output &&
55 test_cmp expect output)
58 test_expect_success 'git fetch --all should continue if a remote has errors' '
59 (git clone one test2 &&
60 cd test2 &&
61 git remote add bad ../non-existing &&
62 git remote add one ../one &&
63 git remote add two ../two &&
64 git remote add three ../three &&
65 test_must_fail git fetch --all &&
66 git branch -r > output &&
67 test_cmp ../test/expect output)
70 test_expect_success 'git fetch --all does not allow non-option arguments' '
71 (cd test &&
72 test_must_fail git fetch --all origin &&
73 test_must_fail git fetch --all origin master)
76 cat > expect << EOF
77 origin/HEAD -> origin/master
78 origin/master
79 origin/side
80 three/another
81 three/master
82 three/side
83 EOF
85 test_expect_success 'git fetch --multiple (but only one remote)' '
86 (git clone one test3 &&
87 cd test3 &&
88 git remote add three ../three &&
89 git fetch --multiple three &&
90 git branch -r > output &&
91 test_cmp ../expect output)
94 cat > expect << EOF
95 one/master
96 one/side
97 two/another
98 two/master
99 two/side
102 test_expect_success 'git fetch --multiple (two remotes)' '
103 (git clone one test4 &&
104 cd test4 &&
105 git remote rm origin &&
106 git remote add one ../one &&
107 git remote add two ../two &&
108 git fetch --multiple one two &&
109 git branch -r > output &&
110 test_cmp ../expect output)
113 test_expect_success 'git fetch --multiple (bad remote names)' '
114 (cd test4 &&
115 test_must_fail git fetch --multiple four)
119 test_expect_success 'git fetch --all (skipFetchAll)' '
120 (cd test4 &&
121 for b in $(git branch -r)
123 git branch -r -d $b || break
124 done &&
125 git remote add three ../three &&
126 git config remote.three.skipFetchAll true &&
127 git fetch --all &&
128 git branch -r > output &&
129 test_cmp ../expect output)
132 cat > expect << EOF
133 one/master
134 one/side
135 three/another
136 three/master
137 three/side
138 two/another
139 two/master
140 two/side
143 test_expect_success 'git fetch --multiple (ignoring skipFetchAll)' '
144 (cd test4 &&
145 for b in $(git branch -r)
147 git branch -r -d $b || break
148 done &&
149 git fetch --multiple one two three &&
150 git branch -r > output &&
151 test_cmp ../expect output)
154 test_done