3 test_description
='unpack-objects'
7 test_expect_success setup
'
9 GIT_DIR=pub.git git init --bare &&
10 GIT_DIR=pub.git git config receive.fsckobjects true &&
15 git config push.default matching &&
20 git config push.default matching &&
23 git commit -m "Initial junk"
26 git commit -m "Initial superproject"
30 test_expect_success push
'
33 git push ../pub.git master
37 test_expect_success
'push if submodule has no remote' '
42 git commit -m "Second junk"
47 git commit -m "Second commit for gar/bage" &&
48 git push --recurse-submodules=check ../pub.git master
52 test_expect_success
'push fails if submodule commit not on remote' '
55 git clone --bare bage ../../submodule.git &&
57 git remote add origin ../../../submodule.git &&
61 git commit -m "Third junk"
66 git commit -m "Third commit for gar/bage" &&
67 # the push should fail with --recurse-submodules=check
68 # on the command line...
69 test_must_fail git push --recurse-submodules=check ../pub.git master &&
71 # ...or if specified in the configuration..
72 test_must_fail git -c push.recurseSubmodules=check push ../pub.git master
76 test_expect_success
'push succeeds after commit was pushed to remote' '
79 git push origin master
83 git push --recurse-submodules=check ../pub.git master
87 test_expect_success
'push succeeds if submodule commit not on remote but using on-demand on command line' '
90 >recurse-on-demand-on-command-line &&
91 git add recurse-on-demand-on-command-line &&
92 git commit -m "Recurse on-demand on command line junk"
97 git commit -m "Recurse on-demand on command line for gar/bage" &&
98 git push --recurse-submodules=on-demand ../pub.git master &&
99 # Check that the supermodule commit got there
100 git fetch ../pub.git &&
101 git diff --quiet FETCH_HEAD master &&
102 # Check that the submodule commit got there too
104 git diff --quiet origin/master master
108 test_expect_success
'push succeeds if submodule commit not on remote but using on-demand from config' '
111 >recurse-on-demand-from-config &&
112 git add recurse-on-demand-from-config &&
113 git commit -m "Recurse on-demand from config junk"
118 git commit -m "Recurse on-demand from config for gar/bage" &&
119 git -c push.recurseSubmodules=on-demand push ../pub.git master &&
120 # Check that the supermodule commit got there
121 git fetch ../pub.git &&
122 git diff --quiet FETCH_HEAD master &&
123 # Check that the submodule commit got there too
125 git diff --quiet origin/master master
129 test_expect_success
'push recurse-submodules on command line overrides config' '
132 >recurse-check-on-command-line-overriding-config &&
133 git add recurse-check-on-command-line-overriding-config &&
134 git commit -m "Recurse on command-line overriding config junk"
139 git commit -m "Recurse on command-line overriding config for gar/bage" &&
141 # Ensure that we can override on-demand in the config
142 # to just check submodules
143 test_must_fail git -c push.recurseSubmodules=on-demand push --recurse-submodules=check ../pub.git master &&
144 # Check that the supermodule commit did not get there
145 git fetch ../pub.git &&
146 git diff --quiet FETCH_HEAD master^ &&
147 # Check that the submodule commit did not get there
148 (cd gar/bage && git diff --quiet origin/master master^) &&
150 # Ensure that we can override check in the config to
151 # disable submodule recursion entirely
152 (cd gar/bage && git diff --quiet origin/master master^) &&
153 git -c push.recurseSubmodules=on-demand push --recurse-submodules=no ../pub.git master &&
154 git fetch ../pub.git &&
155 git diff --quiet FETCH_HEAD master &&
156 (cd gar/bage && git diff --quiet origin/master master^) &&
158 # Ensure that we can override check in the config to
159 # disable submodule recursion entirely (alternative form)
160 git -c push.recurseSubmodules=on-demand push --no-recurse-submodules ../pub.git master &&
161 git fetch ../pub.git &&
162 git diff --quiet FETCH_HEAD master &&
163 (cd gar/bage && git diff --quiet origin/master master^) &&
165 # Ensure that we can override check in the config to
166 # push the submodule too
167 git -c push.recurseSubmodules=check push --recurse-submodules=on-demand ../pub.git master &&
168 git fetch ../pub.git &&
169 git diff --quiet FETCH_HEAD master &&
170 (cd gar/bage && git diff --quiet origin/master master)
174 test_expect_success
'push recurse-submodules last one wins on command line' '
177 >recurse-check-on-command-line-overriding-earlier-command-line &&
178 git add recurse-check-on-command-line-overriding-earlier-command-line &&
179 git commit -m "Recurse on command-line overridiing earlier command-line junk"
184 git commit -m "Recurse on command-line overriding earlier command-line for gar/bage" &&
186 # should result in "check"
187 test_must_fail git push --recurse-submodules=on-demand --recurse-submodules=check ../pub.git master &&
188 # Check that the supermodule commit did not get there
189 git fetch ../pub.git &&
190 git diff --quiet FETCH_HEAD master^ &&
191 # Check that the submodule commit did not get there
192 (cd gar/bage && git diff --quiet origin/master master^) &&
194 # should result in "no"
195 git push --recurse-submodules=on-demand --recurse-submodules=no ../pub.git master &&
196 # Check that the supermodule commit did get there
197 git fetch ../pub.git &&
198 git diff --quiet FETCH_HEAD master &&
199 # Check that the submodule commit did not get there
200 (cd gar/bage && git diff --quiet origin/master master^) &&
202 # should result in "no"
203 git push --recurse-submodules=on-demand --no-recurse-submodules ../pub.git master &&
204 # Check that the submodule commit did not get there
205 (cd gar/bage && git diff --quiet origin/master master^) &&
207 # But the options in the other order should push the submodule
208 git push --recurse-submodules=check --recurse-submodules=on-demand ../pub.git master &&
209 # Check that the submodule commit did get there
210 git fetch ../pub.git &&
211 (cd gar/bage && git diff --quiet origin/master master)
215 test_expect_success
'push succeeds if submodule commit not on remote using on-demand from cmdline overriding config' '
218 >recurse-on-demand-on-command-line-overriding-config &&
219 git add recurse-on-demand-on-command-line-overriding-config &&
220 git commit -m "Recurse on-demand on command-line overriding config junk"
225 git commit -m "Recurse on-demand on command-line overriding config for gar/bage" &&
226 git -c push.recurseSubmodules=check push --recurse-submodules=on-demand ../pub.git master &&
227 # Check that the supermodule commit got there
228 git fetch ../pub.git &&
229 git diff --quiet FETCH_HEAD master &&
230 # Check that the submodule commit got there
232 git diff --quiet origin/master master
236 test_expect_success
'push succeeds if submodule commit disabling recursion from cmdline overriding config' '
239 >recurse-disable-on-command-line-overriding-config &&
240 git add recurse-disable-on-command-line-overriding-config &&
241 git commit -m "Recurse disable on command-line overriding config junk"
246 git commit -m "Recurse disable on command-line overriding config for gar/bage" &&
247 git -c push.recurseSubmodules=check push --recurse-submodules=no ../pub.git master &&
248 # Check that the supermodule commit got there
249 git fetch ../pub.git &&
250 git diff --quiet FETCH_HEAD master &&
251 # But that the submodule commit did not
252 ( cd gar/bage && git diff --quiet origin/master master^ ) &&
253 # Now push it to avoid confusing future tests
254 git push --recurse-submodules=on-demand ../pub.git master
258 test_expect_success
'push succeeds if submodule commit disabling recursion from cmdline (alternative form) overriding config' '
261 >recurse-disable-on-command-line-alt-overriding-config &&
262 git add recurse-disable-on-command-line-alt-overriding-config &&
263 git commit -m "Recurse disable on command-line alternative overriding config junk"
268 git commit -m "Recurse disable on command-line alternative overriding config for gar/bage" &&
269 git -c push.recurseSubmodules=check push --no-recurse-submodules ../pub.git master &&
270 # Check that the supermodule commit got there
271 git fetch ../pub.git &&
272 git diff --quiet FETCH_HEAD master &&
273 # But that the submodule commit did not
274 ( cd gar/bage && git diff --quiet origin/master master^ ) &&
275 # Now push it to avoid confusing future tests
276 git push --recurse-submodules=on-demand ../pub.git master
280 test_expect_success
'push fails if recurse submodules option passed as yes' '
283 >recurse-push-fails-if-recurse-submodules-passed-as-yes &&
284 git add recurse-push-fails-if-recurse-submodules-passed-as-yes &&
285 git commit -m "Recurse push fails if recurse submodules option passed as yes"
290 git commit -m "Recurse push fails if recurse submodules option passed as yes for gar/bage" &&
291 test_must_fail git push --recurse-submodules=yes ../pub.git master &&
292 test_must_fail git -c push.recurseSubmodules=yes push ../pub.git master &&
293 git push --recurse-submodules=on-demand ../pub.git master
297 test_expect_success
'push fails when commit on multiple branches if one branch has no remote' '
302 git commit -m "Fourth junk"
306 git branch branch2 &&
308 git commit -m "Fourth commit for gar/bage" &&
309 git checkout branch2 &&
316 git commit -m "First junk" &&
317 test_must_fail git push --recurse-submodules=check ../pub.git
321 test_expect_success
'push succeeds if submodule has no remote and is on the first superproject commit' '
331 git commit -m "initial"
334 git commit -m "added submodule" &&
335 git push --recurse-submodule=check origin master
339 test_expect_success
'push unpushed submodules when not needed' '
344 git checkout master &&
347 git commit -m "Fifth junk" &&
349 git rev-parse origin/master >../../../expected
351 git checkout master &&
353 git commit -m "Fifth commit for gar/bage" &&
354 git push --recurse-submodules=on-demand ../pub.git master
358 git rev-parse master >../actual
360 test_cmp expected actual
363 test_expect_success
'push unpushed submodules when not needed 2' '
366 git rev-parse master >../expected
374 git commit -m "Sixth junk"
378 git commit -m "Second junk for work" &&
379 git push --recurse-submodules=on-demand ../pub.git master
383 git rev-parse master >../actual
385 test_cmp expected actual
388 test_expect_success
'push unpushed submodules recursively' '
393 git checkout master &&
396 git commit -m "Seventh junk" &&
397 git rev-parse master >../../../expected
399 git checkout master &&
401 git commit -m "Seventh commit for gar/bage" &&
402 git push --recurse-submodules=on-demand ../pub.git master
406 git rev-parse master >../actual
408 test_cmp expected actual
411 test_expect_success
'push unpushable submodule recursively fails' '
416 git rev-parse origin/master >../../../expected &&
417 git checkout master~0 &&
420 git commit -m "Eighth junk"
423 git commit -m "Eighth commit for gar/bage" &&
424 test_must_fail git push --recurse-submodules=on-demand ../pub.git master
428 git rev-parse master >../actual
430 test_when_finished git -C work reset --hard master^ &&
431 test_cmp expected actual
434 test_expect_success
'push --dry-run does not recursively update submodules' '
437 git checkout master &&
438 git rev-parse master >../../../expected_submodule &&
441 git commit -m "Ninth junk" &&
443 # Go up to 'work
' directory
445 git checkout master &&
446 git rev-parse master >../expected_pub &&
448 git commit -m "Ninth commit for gar/bage" &&
449 git push --dry-run --recurse-submodules=on-demand ../pub.git master
451 git -C submodule.git rev-parse master >actual_submodule &&
452 git -C pub.git rev-parse master >actual_pub &&
453 test_cmp expected_pub actual_pub &&
454 test_cmp expected_submodule actual_submodule