]> git.ipfire.org Git - thirdparty/git.git/blame - t/t5514-fetch-multiple.sh
Sync with 2.36.3
[thirdparty/git.git] / t / t5514-fetch-multiple.sh
CommitLineData
9c4a036b
BG
1#!/bin/sh
2
3test_description='fetch --all works correctly'
4
bc925ce3 5GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME=main
334afbc7
JS
6export GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME
7
9c4a036b
BG
8. ./test-lib.sh
9
10setup_repository () {
11 mkdir "$1" && (
12 cd "$1" &&
13 git init &&
14 >file &&
15 git add file &&
16 test_tick &&
17 git commit -m "Initial" &&
18 git checkout -b side &&
19 >elif &&
20 git add elif &&
21 test_tick &&
22 git commit -m "Second" &&
bc925ce3 23 git checkout main
9c4a036b
BG
24 )
25}
26
27test_expect_success setup '
28 setup_repository one &&
29 setup_repository two &&
30 (
31 cd two && git branch another
32 ) &&
a48fcd83 33 git clone --mirror two three &&
9c4a036b
BG
34 git clone one test
35'
36
37cat > test/expect << EOF
bc925ce3 38 one/main
9c4a036b 39 one/side
bc925ce3
JS
40 origin/HEAD -> origin/main
41 origin/main
9c4a036b
BG
42 origin/side
43 three/another
bc925ce3 44 three/main
9c4a036b
BG
45 three/side
46 two/another
bc925ce3 47 two/main
9c4a036b
BG
48 two/side
49EOF
50
51test_expect_success 'git fetch --all' '
52 (cd test &&
53 git remote add one ../one &&
54 git remote add two ../two &&
55 git remote add three ../three &&
56 git fetch --all &&
57 git branch -r > output &&
58 test_cmp expect output)
59'
60
61test_expect_success 'git fetch --all should continue if a remote has errors' '
62 (git clone one test2 &&
63 cd test2 &&
64 git remote add bad ../non-existing &&
65 git remote add one ../one &&
66 git remote add two ../two &&
67 git remote add three ../three &&
68 test_must_fail git fetch --all &&
69 git branch -r > output &&
70 test_cmp ../test/expect output)
71'
72
73test_expect_success 'git fetch --all does not allow non-option arguments' '
74 (cd test &&
75 test_must_fail git fetch --all origin &&
bc925ce3 76 test_must_fail git fetch --all origin main)
9c4a036b
BG
77'
78
16679e37 79cat > expect << EOF
bc925ce3
JS
80 origin/HEAD -> origin/main
81 origin/main
16679e37
BG
82 origin/side
83 three/another
bc925ce3 84 three/main
16679e37
BG
85 three/side
86EOF
87
88test_expect_success 'git fetch --multiple (but only one remote)' '
89 (git clone one test3 &&
90 cd test3 &&
91 git remote add three ../three &&
92 git fetch --multiple three &&
93 git branch -r > output &&
94 test_cmp ../expect output)
95'
96
97cat > expect << EOF
bc925ce3 98 one/main
16679e37 99 one/side
16679e37 100 two/another
bc925ce3 101 two/main
16679e37
BG
102 two/side
103EOF
104
105test_expect_success 'git fetch --multiple (two remotes)' '
106 (git clone one test4 &&
107 cd test4 &&
7cc91a2f 108 git remote rm origin &&
16679e37
BG
109 git remote add one ../one &&
110 git remote add two ../two &&
c3d6b703 111 GIT_TRACE=1 git fetch --multiple one two 2>trace &&
16679e37 112 git branch -r > output &&
c3d6b703 113 test_cmp ../expect output &&
916d0626 114 grep "built-in: git maintenance" trace >gc &&
c3d6b703
NTND
115 test_line_count = 1 gc
116 )
16679e37
BG
117'
118
119test_expect_success 'git fetch --multiple (bad remote names)' '
120 (cd test4 &&
121 test_must_fail git fetch --multiple four)
122'
123
7cc91a2f
BG
124
125test_expect_success 'git fetch --all (skipFetchAll)' '
126 (cd test4 &&
127 for b in $(git branch -r)
128 do
e6821d09 129 git branch -r -d $b || exit 1
7cc91a2f
BG
130 done &&
131 git remote add three ../three &&
132 git config remote.three.skipFetchAll true &&
133 git fetch --all &&
134 git branch -r > output &&
135 test_cmp ../expect output)
136'
137
138cat > expect << EOF
bc925ce3 139 one/main
7cc91a2f
BG
140 one/side
141 three/another
bc925ce3 142 three/main
7cc91a2f
BG
143 three/side
144 two/another
bc925ce3 145 two/main
7cc91a2f
BG
146 two/side
147EOF
148
149test_expect_success 'git fetch --multiple (ignoring skipFetchAll)' '
150 (cd test4 &&
151 for b in $(git branch -r)
152 do
e6821d09 153 git branch -r -d $b || exit 1
7cc91a2f
BG
154 done &&
155 git fetch --multiple one two three &&
156 git branch -r > output &&
157 test_cmp ../expect output)
158'
159
85566460 160test_expect_success 'git fetch --all --no-tags' '
85566460
DJ
161 git clone one test5 &&
162 git clone test5 test6 &&
163 (cd test5 && git tag test-tag) &&
164 (
165 cd test6 &&
166 git fetch --all --no-tags &&
167 git tag >output
168 ) &&
d3c6751b 169 test_must_be_empty test6/output
85566460
DJ
170'
171
172test_expect_success 'git fetch --all --tags' '
173 echo test-tag >expect &&
174 git clone one test7 &&
175 git clone test7 test8 &&
176 (
177 cd test7 &&
178 test_commit test-tag &&
179 git reset --hard HEAD^
180 ) &&
181 (
182 cd test8 &&
183 git fetch --all --tags &&
184 git tag >output
185 ) &&
186 test_cmp expect test8/output
187'
188
d54dea77
JS
189test_expect_success 'parallel' '
190 git remote add one ./bogus1 &&
191 git remote add two ./bogus2 &&
192
193 test_must_fail env GIT_TRACE="$PWD/trace" \
194 git fetch --jobs=2 --multiple one two 2>err &&
195 grep "preparing to run up to 2 tasks" trace &&
196 test_i18ngrep "could not fetch .one.*128" err &&
197 test_i18ngrep "could not fetch .two.*128" err
198'
199
9c4a036b 200test_done