builtin/gc.c: ignore cruft packs with `--keep-largest-pack`
[alt-git.git] / t / t5514-fetch-multiple.sh
blob98f034aa77bb243492ea1232549f7d1ec195a152
1 #!/bin/sh
3 test_description='fetch --all works correctly'
5 GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME=main
6 export GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME
8 . ./test-lib.sh
10 setup_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" &&
23 git checkout main
27 test_expect_success setup '
28 setup_repository one &&
29 setup_repository two &&
31 cd two && git branch another
32 ) &&
33 git clone --mirror two three &&
34 git clone one test
37 cat > test/expect << EOF
38 one/main
39 one/side
40 origin/HEAD -> origin/main
41 origin/main
42 origin/side
43 three/another
44 three/main
45 three/side
46 two/another
47 two/main
48 two/side
49 EOF
51 test_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)
61 test_expect_success 'git fetch --all --no-write-fetch-head' '
62 (cd test &&
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 &&
70 cd 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' '
81 (cd test &&
82 test_must_fail git fetch --all origin &&
83 test_must_fail git fetch --all origin main)
86 cat > expect << EOF
87 origin/HEAD -> origin/main
88 origin/main
89 origin/side
90 three/another
91 three/main
92 three/side
93 EOF
95 test_expect_success 'git fetch --multiple (but only one remote)' '
96 (git clone one test3 &&
97 cd test3 &&
98 git remote add three ../three &&
99 git fetch --multiple three &&
100 git branch -r > output &&
101 test_cmp ../expect output)
104 cat > expect << EOF
105 one/main
106 one/side
107 two/another
108 two/main
109 two/side
112 test_expect_success 'git fetch --multiple (two remotes)' '
113 (git clone one test4 &&
114 cd 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)' '
127 (cd test4 &&
128 test_must_fail git fetch --multiple four)
132 test_expect_success 'git fetch --all (skipFetchAll)' '
133 (cd test4 &&
134 for b in $(git branch -r)
136 git branch -r -d $b || exit 1
137 done &&
138 git remote add three ../three &&
139 git config remote.three.skipFetchAll true &&
140 git fetch --all &&
141 git branch -r > output &&
142 test_cmp ../expect output)
145 cat > expect << EOF
146 one/main
147 one/side
148 three/another
149 three/main
150 three/side
151 two/another
152 two/main
153 two/side
156 test_expect_success 'git fetch --multiple (ignoring skipFetchAll)' '
157 (cd test4 &&
158 for b in $(git branch -r)
160 git branch -r -d $b || exit 1
161 done &&
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) &&
172 cd test6 &&
173 git fetch --all --no-tags &&
174 git tag >output
175 ) &&
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 &&
184 cd test7 &&
185 test_commit test-tag &&
186 git reset --hard HEAD^
187 ) &&
189 cd test8 &&
190 git fetch --all --tags &&
191 git tag >output
192 ) &&
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' '
208 (cd test &&
209 git fetch --multiple --jobs=0)
212 test_done