]> git.ipfire.org Git - thirdparty/git.git/blame - t/t5514-fetch-multiple.sh
Merge branch 'bw/format-patch-o-create-leading-dirs'
[thirdparty/git.git] / t / t5514-fetch-multiple.sh
CommitLineData
9c4a036b
BG
1#!/bin/sh
2
3test_description='fetch --all works correctly'
4
5. ./test-lib.sh
6
7setup_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
21 )
22}
23
24test_expect_success setup '
25 setup_repository one &&
26 setup_repository two &&
27 (
28 cd two && git branch another
29 ) &&
a48fcd83 30 git clone --mirror two three &&
9c4a036b
BG
31 git clone one test
32'
33
34cat > 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
46EOF
47
48test_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)
56'
57
58test_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)
68'
69
70test_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)
74'
75
16679e37
BG
76cat > expect << EOF
77 origin/HEAD -> origin/master
78 origin/master
79 origin/side
80 three/another
81 three/master
82 three/side
83EOF
84
85test_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)
92'
93
94cat > expect << EOF
95 one/master
96 one/side
16679e37
BG
97 two/another
98 two/master
99 two/side
100EOF
101
102test_expect_success 'git fetch --multiple (two remotes)' '
103 (git clone one test4 &&
104 cd test4 &&
7cc91a2f 105 git remote rm origin &&
16679e37
BG
106 git remote add one ../one &&
107 git remote add two ../two &&
c3d6b703 108 GIT_TRACE=1 git fetch --multiple one two 2>trace &&
16679e37 109 git branch -r > output &&
c3d6b703
NTND
110 test_cmp ../expect output &&
111 grep "built-in: git gc" trace >gc &&
112 test_line_count = 1 gc
113 )
16679e37
BG
114'
115
116test_expect_success 'git fetch --multiple (bad remote names)' '
117 (cd test4 &&
118 test_must_fail git fetch --multiple four)
119'
120
7cc91a2f
BG
121
122test_expect_success 'git fetch --all (skipFetchAll)' '
123 (cd test4 &&
124 for b in $(git branch -r)
125 do
e6821d09 126 git branch -r -d $b || exit 1
7cc91a2f
BG
127 done &&
128 git remote add three ../three &&
129 git config remote.three.skipFetchAll true &&
130 git fetch --all &&
131 git branch -r > output &&
132 test_cmp ../expect output)
133'
134
135cat > expect << EOF
136 one/master
137 one/side
138 three/another
139 three/master
140 three/side
141 two/another
142 two/master
143 two/side
144EOF
145
146test_expect_success 'git fetch --multiple (ignoring skipFetchAll)' '
147 (cd test4 &&
148 for b in $(git branch -r)
149 do
e6821d09 150 git branch -r -d $b || exit 1
7cc91a2f
BG
151 done &&
152 git fetch --multiple one two three &&
153 git branch -r > output &&
154 test_cmp ../expect output)
155'
156
85566460 157test_expect_success 'git fetch --all --no-tags' '
85566460
DJ
158 git clone one test5 &&
159 git clone test5 test6 &&
160 (cd test5 && git tag test-tag) &&
161 (
162 cd test6 &&
163 git fetch --all --no-tags &&
164 git tag >output
165 ) &&
d3c6751b 166 test_must_be_empty test6/output
85566460
DJ
167'
168
169test_expect_success 'git fetch --all --tags' '
170 echo test-tag >expect &&
171 git clone one test7 &&
172 git clone test7 test8 &&
173 (
174 cd test7 &&
175 test_commit test-tag &&
176 git reset --hard HEAD^
177 ) &&
178 (
179 cd test8 &&
180 git fetch --all --tags &&
181 git tag >output
182 ) &&
183 test_cmp expect test8/output
184'
185
d54dea77
JS
186test_expect_success 'parallel' '
187 git remote add one ./bogus1 &&
188 git remote add two ./bogus2 &&
189
190 test_must_fail env GIT_TRACE="$PWD/trace" \
191 git fetch --jobs=2 --multiple one two 2>err &&
192 grep "preparing to run up to 2 tasks" trace &&
193 test_i18ngrep "could not fetch .one.*128" err &&
194 test_i18ngrep "could not fetch .two.*128" err
195'
196
9c4a036b 197test_done