@@ -64,7 +64,12 @@ test_expect_success 'push fails if submodule commit not on remote' '
64
64
cd work &&
65
65
git add gar/bage &&
66
66
git commit -m "Third commit for gar/bage" &&
67
- test_must_fail git push --recurse-submodules=check ../pub.git master
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 &&
70
+
71
+ # ...or if specified in the configuration..
72
+ test_must_fail git -c push.recurseSubmodules=check push ../pub.git master
68
73
)
69
74
'
70
75
@@ -79,6 +84,151 @@ test_expect_success 'push succeeds after commit was pushed to remote' '
79
84
)
80
85
'
81
86
87
+ test_expect_success ' push succeeds if submodule commit not on remote but using on-demand on command line' '
88
+ (
89
+ cd work/gar/bage &&
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"
93
+ ) &&
94
+ (
95
+ cd work &&
96
+ git add gar/bage &&
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
103
+ cd gar/bage &&
104
+ git diff --quiet origin/master master
105
+ )
106
+ '
107
+
108
+ test_expect_success ' push succeeds if submodule commit not on remote but using on-demand from config' '
109
+ (
110
+ cd work/gar/bage &&
111
+ >recurse-on-demand-from-config &&
112
+ git add recurse-on-demand-from-config &&
113
+ git commit -m "Recurse on-demand from config junk"
114
+ ) &&
115
+ (
116
+ cd work &&
117
+ git add gar/bage &&
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
124
+ cd gar/bage &&
125
+ git diff --quiet origin/master master
126
+ )
127
+ '
128
+
129
+ test_expect_success ' push fails if submodule commit not on remote using check from cmdline overriding config' '
130
+ (
131
+ cd work/gar/bage &&
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"
135
+ ) &&
136
+ (
137
+ cd work &&
138
+ git add gar/bage &&
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
145
+ cd gar/bage &&
146
+ git diff --quiet origin/master master^
147
+ )
148
+ '
149
+
150
+ test_expect_success ' push succeeds if submodule commit not on remote using on-demand from cmdline overriding config' '
151
+ (
152
+ cd work/gar/bage &&
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"
156
+ ) &&
157
+ (
158
+ cd work &&
159
+ git add gar/bage &&
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
166
+ cd gar/bage &&
167
+ git diff --quiet origin/master master
168
+ )
169
+ '
170
+
171
+ test_expect_success ' push succeeds if submodule commit disabling recursion from cmdline overriding config' '
172
+ (
173
+ cd work/gar/bage &&
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"
177
+ ) &&
178
+ (
179
+ cd work &&
180
+ git add gar/bage &&
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
190
+ )
191
+ '
192
+
193
+ test_expect_success ' push succeeds if submodule commit disabling recursion from cmdline (alternative form) overriding config' '
194
+ (
195
+ cd work/gar/bage &&
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"
199
+ ) &&
200
+ (
201
+ cd work &&
202
+ git add gar/bage &&
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
212
+ )
213
+ '
214
+
215
+ test_expect_success ' push fails if recurse submodules option passed as yes' '
216
+ (
217
+ cd work/gar/bage &&
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"
221
+ ) &&
222
+ (
223
+ cd work &&
224
+ git add gar/bage &&
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
229
+ )
230
+ '
231
+
82
232
test_expect_success ' push fails when commit on multiple branches if one branch has no remote' '
83
233
(
84
234
cd work/gar/bage &&
0 commit comments