3 test_description
='fetch --all works correctly'
5 GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME
=main
6 export GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME
17 git commit
-m "Initial" &&
18 git checkout
-b side
&&
22 git commit
-m "Second" &&
27 test_expect_success setup
'
28 setup_repository one &&
29 setup_repository two &&
31 cd two && git branch another
33 git clone --mirror two three &&
37 cat > test
/expect
<< EOF
40 origin/HEAD -> origin/main
51 test_expect_success
'git fetch --all' '
53 git remote add one ../one &&
54 git remote add two ../two &&
55 git remote add three ../three &&
57 git branch -r > output &&
58 test_cmp expect output)
61 test_expect_success
'git fetch --all --no-write-fetch-head' '
63 rm -f .git/FETCH_HEAD &&
64 git fetch --all --no-write-fetch-head &&
65 test_path_is_missing .git/FETCH_HEAD)
68 test_expect_success
'git fetch --all should continue if a remote has errors' '
69 (git clone one test2 &&
71 git remote add bad ../non-existing &&
72 git remote add one ../one &&
73 git remote add two ../two &&
74 git remote add three ../three &&
75 test_must_fail git fetch --all &&
76 git branch -r > output &&
77 test_cmp ../test/expect output)
80 test_expect_success
'git fetch --all does not allow non-option arguments' '
82 test_must_fail git fetch --all origin &&
83 test_must_fail git fetch --all origin main)
87 origin/HEAD -> origin/main
95 test_expect_success
'git fetch --multiple (but only one remote)' '
96 (git clone one test3 &&
98 git remote add three ../three &&
99 git fetch --multiple three &&
100 git branch -r > output &&
101 test_cmp ../expect output)
112 test_expect_success
'git fetch --multiple (two remotes)' '
113 (git clone one test4 &&
115 git remote rm origin &&
116 git remote add one ../one &&
117 git remote add two ../two &&
118 GIT_TRACE=1 git fetch --multiple one two 2>trace &&
119 git branch -r > output &&
120 test_cmp ../expect output &&
121 grep "built-in: git maintenance" trace >gc &&
122 test_line_count = 1 gc
126 test_expect_success
'git fetch --multiple (bad remote names)' '
128 test_must_fail git fetch --multiple four)
132 test_expect_success
'git fetch --all (skipFetchAll)' '
134 for b in $(git branch -r)
136 git branch -r -d $b || exit 1
138 git remote add three ../three &&
139 git config remote.three.skipFetchAll true &&
141 git branch -r > output &&
142 test_cmp ../expect output)
156 test_expect_success
'git fetch --multiple (ignoring skipFetchAll)' '
158 for b in $(git branch -r)
160 git branch -r -d $b || exit 1
162 git fetch --multiple one two three &&
163 git branch -r > output &&
164 test_cmp ../expect output)
167 test_expect_success
'git fetch --all --no-tags' '
168 git clone one test5 &&
169 git clone test5 test6 &&
170 (cd test5 && git tag test-tag) &&
173 git fetch --all --no-tags &&
176 test_must_be_empty test6/output
179 test_expect_success
'git fetch --all --tags' '
180 echo test-tag >expect &&
181 git clone one test7 &&
182 git clone test7 test8 &&
185 test_commit test-tag &&
186 git reset --hard HEAD^
190 git fetch --all --tags &&
193 test_cmp expect test8/output
196 test_expect_success
'parallel' '
197 git remote add one ./bogus1 &&
198 git remote add two ./bogus2 &&
200 test_must_fail env GIT_TRACE="$PWD/trace" \
201 git fetch --jobs=2 --multiple one two 2>err &&
202 grep "preparing to run up to 2 tasks" trace &&
203 test_i18ngrep "could not fetch .one.*128" err &&
204 test_i18ngrep "could not fetch .two.*128" err
207 test_expect_success
'git fetch --multiple --jobs=0 picks a default' '
209 git fetch --multiple --jobs=0)