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 fails if submodule commit not on remote using check from cmdline overriding 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 overridiing config junk"
139 git commit -m "Recurse on command-line overriding config for gar/bage" &&
140 test_must_fail git -c push.recurseSubmodules=on-demand push --recurse-submodules=check ../pub.git master &&
141 # Check that the supermodule commit did not get there
142 git fetch ../pub.git &&
143 git diff --quiet FETCH_HEAD master^ &&
144 # Check that the submodule commit did not get there
146 git diff --quiet origin/master master^
150 test_expect_success 'push succeeds if submodule commit not on remote using on-demand from cmdline overriding config' '
153 >recurse-on-demand-on-command-line-overriding-config &&
154 git add recurse-on-demand-on-command-line-overriding-config &&
155 git commit -m "Recurse on-demand on command-line overriding config junk"
160 git commit -m "Recurse on-demand on command-line overriding config for gar/bage" &&
161 git -c push.recurseSubmodules=check push --recurse-submodules=on-demand ../pub.git master &&
162 # Check that the supermodule commit got there
163 git fetch ../pub.git &&
164 git diff --quiet FETCH_HEAD master &&
165 # Check that the submodule commit got there
167 git diff --quiet origin/master master
171 test_expect_success 'push succeeds if submodule commit disabling recursion from cmdline overriding config' '
174 >recurse-disable-on-command-line-overriding-config &&
175 git add recurse-disable-on-command-line-overriding-config &&
176 git commit -m "Recurse disable on command-line overriding config junk"
181 git commit -m "Recurse disable on command-line overriding config for gar/bage" &&
182 git -c push.recurseSubmodules=check push --recurse-submodules=no ../pub.git master &&
183 # Check that the supermodule commit got there
184 git fetch ../pub.git &&
185 git diff --quiet FETCH_HEAD master &&
186 # But that the submodule commit did not
187 ( cd gar/bage && git diff --quiet origin/master master^ ) &&
188 # Now push it to avoid confusing future tests
189 git push --recurse-submodules=on-demand ../pub.git master
193 test_expect_success 'push succeeds if submodule commit disabling recursion from cmdline (alternative form) overriding config' '
196 >recurse-disable-on-command-line-alt-overriding-config &&
197 git add recurse-disable-on-command-line-alt-overriding-config &&
198 git commit -m "Recurse disable on command-line alternative overriding config junk"
203 git commit -m "Recurse disable on command-line alternative overriding config for gar/bage" &&
204 git -c push.recurseSubmodules=check push --no-recurse-submodules ../pub.git master &&
205 # Check that the supermodule commit got there
206 git fetch ../pub.git &&
207 git diff --quiet FETCH_HEAD master &&
208 # But that the submodule commit did not
209 ( cd gar/bage && git diff --quiet origin/master master^ ) &&
210 # Now push it to avoid confusing future tests
211 git push --recurse-submodules=on-demand ../pub.git master
215 test_expect_success 'push fails if recurse submodules option passed as yes' '
218 >recurse-push-fails-if-recurse-submodules-passed-as-yes &&
219 git add recurse-push-fails-if-recurse-submodules-passed-as-yes &&
220 git commit -m "Recurse push fails if recurse submodules option passed as yes"
225 git commit -m "Recurse push fails if recurse submodules option passed as yes for gar/bage" &&
226 test_must_fail git push --recurse-submodules=yes ../pub.git master &&
227 test_must_fail git -c push.recurseSubmodules=yes push ../pub.git master &&
228 git push --recurse-submodules=on-demand ../pub.git master
232 test_expect_success 'push fails when commit on multiple branches if one branch has no remote' '
237 git commit -m "Fourth junk"
241 git branch branch2 &&
243 git commit -m "Fourth commit for gar/bage" &&
244 git checkout branch2 &&
251 git commit -m "First junk" &&
252 test_must_fail git push --recurse-submodules=check ../pub.git
256 test_expect_success 'push succeeds if submodule has no remote and is on the first superproject commit' '
266 git commit -m "initial"
269 git commit -m "added submodule" &&
270 git push --recurse-submodule=check origin master
274 test_expect_success 'push unpushed submodules when not needed' '
279 git checkout master &&
282 git commit -m "Fifth junk" &&
284 git rev-parse origin/master >../../../expected
286 git checkout master &&
288 git commit -m "Fifth commit for gar/bage" &&
289 git push --recurse-submodules=on-demand ../pub.git master
293 git rev-parse master >../actual
295 test_cmp expected actual
298 test_expect_success 'push unpushed submodules when not needed 2' '
301 git rev-parse master >../expected
309 git commit -m "Sixth junk"
313 git commit -m "Second junk for work" &&
314 git push --recurse-submodules=on-demand ../pub.git master
318 git rev-parse master >../actual
320 test_cmp expected actual
323 test_expect_success 'push unpushed submodules recursively' '
328 git checkout master &&
331 git commit -m "Seventh junk" &&
332 git rev-parse master >../../../expected
334 git checkout master &&
336 git commit -m "Seventh commit for gar/bage" &&
337 git push --recurse-submodules=on-demand ../pub.git master
341 git rev-parse master >../actual
343 test_cmp expected actual
346 test_expect_success 'push unpushable submodule recursively fails' '
351 git rev-parse origin/master >../../../expected &&
352 git checkout master~0 &&
355 git commit -m "Eighth junk"
358 git commit -m "Eighth commit for gar/bage" &&
359 test_must_fail git push --recurse-submodules=on-demand ../pub.git master
363 git rev-parse master >../actual
365 test_cmp expected actual