compat/fsmonitor/fsm-listen-darwin: add MacOS header files for FSEvent
[git/debian.git] / t / t5514-fetch-multiple.sh
blob511ba3bd454808943c73298c7c8f44a0b5bb9c7a
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 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)
73 test_expect_success 'git fetch --all does not allow non-option arguments' '
74 (cd test &&
75 test_must_fail git fetch --all origin &&
76 test_must_fail git fetch --all origin main)
79 cat > expect << EOF
80 origin/HEAD -> origin/main
81 origin/main
82 origin/side
83 three/another
84 three/main
85 three/side
86 EOF
88 test_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)
97 cat > expect << EOF
98 one/main
99 one/side
100 two/another
101 two/main
102 two/side
105 test_expect_success 'git fetch --multiple (two remotes)' '
106 (git clone one test4 &&
107 cd 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)' '
120 (cd test4 &&
121 test_must_fail git fetch --multiple four)
125 test_expect_success 'git fetch --all (skipFetchAll)' '
126 (cd test4 &&
127 for b in $(git branch -r)
129 git branch -r -d $b || exit 1
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)
138 cat > expect << EOF
139 one/main
140 one/side
141 three/another
142 three/main
143 three/side
144 two/another
145 two/main
146 two/side
149 test_expect_success 'git fetch --multiple (ignoring skipFetchAll)' '
150 (cd test4 &&
151 for b in $(git branch -r)
153 git branch -r -d $b || exit 1
154 done &&
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) &&
165 cd test6 &&
166 git fetch --all --no-tags &&
167 git tag >output
168 ) &&
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 &&
177 cd test7 &&
178 test_commit test-tag &&
179 git reset --hard HEAD^
180 ) &&
182 cd test8 &&
183 git fetch --all --tags &&
184 git tag >output
185 ) &&
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
200 test_done