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 should continue if a remote has errors' '
62 (git clone one 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)
73 test_expect_success 'git fetch --all does not allow non-option arguments' '
75 test_must_fail git fetch --all origin &&
76 test_must_fail git fetch --all origin main)
80 origin/HEAD -> origin/main
88 test_expect_success 'git fetch --multiple (but only one remote)' '
89 (git clone one test3 &&
91 git remote add three ../three &&
92 git fetch --multiple three &&
93 git branch -r > output &&
94 test_cmp ../expect output)
105 test_expect_success 'git fetch --multiple (two remotes)' '
106 (git clone one test4 &&
108 git remote rm origin &&
109 git remote add one ../one &&
110 git remote add two ../two &&
111 GIT_TRACE=1 git fetch --multiple one two 2>trace &&
112 git branch -r > output &&
113 test_cmp ../expect output &&
114 grep "built-in: git maintenance" trace >gc &&
115 test_line_count = 1 gc
119 test_expect_success 'git fetch --multiple (bad remote names)' '
121 test_must_fail git fetch --multiple four)
125 test_expect_success 'git fetch --all (skipFetchAll)' '
127 for b in $(git branch -r)
129 git branch -r -d $b || exit 1
131 git remote add three ../three &&
132 git config remote.three.skipFetchAll true &&
134 git branch -r > output &&
135 test_cmp ../expect output)
149 test_expect_success 'git fetch --multiple (ignoring skipFetchAll)' '
151 for b in $(git branch -r)
153 git branch -r -d $b || exit 1
155 git fetch --multiple one two three &&
156 git branch -r > output &&
157 test_cmp ../expect output)
160 test_expect_success 'git fetch --all --no-tags' '
161 git clone one test5 &&
162 git clone test5 test6 &&
163 (cd test5 && git tag test-tag) &&
166 git fetch --all --no-tags &&
169 test_must_be_empty test6/output
172 test_expect_success 'git fetch --all --tags' '
173 echo test-tag >expect &&
174 git clone one test7 &&
175 git clone test7 test8 &&
178 test_commit test-tag &&
179 git reset --hard HEAD^
183 git fetch --all --tags &&
186 test_cmp expect test8/output
189 test_expect_success 'parallel' '
190 git remote add one ./bogus1 &&
191 git remote add two ./bogus2 &&
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