@@ -94,15 +94,17 @@ setup_upstream_and_workbench () {
94
94
fi
95
95
upstream=" $1 "
96
96
97
- # Upstream after setup : main(B) foo(A) bar(A) baz(A)
98
- # Workbench after setup : main(A)
97
+ # Upstream after setup: main(B) foo(A) bar(A) baz(A)
98
+ # Workbench after setup: main(A) baz(A) next (A)
99
99
test_expect_success " setup upstream repository and workbench" '
100
100
setup_upstream "$upstream" &&
101
101
rm -rf workbench &&
102
102
git clone "$upstream" workbench &&
103
103
(
104
104
cd workbench &&
105
105
git update-ref refs/heads/main $A &&
106
+ git update-ref refs/heads/baz $A &&
107
+ git update-ref refs/heads/next $A &&
106
108
# Try to make a stable fixed width for abbreviated commit ID,
107
109
# this fixed-width oid will be replaced with "<OID>".
108
110
git config core.abbrev 7 &&
@@ -131,19 +133,14 @@ run_git_push_porcelain_output_test() {
131
133
# Refs of upstream : main(B) foo(A) bar(A) baz(A)
132
134
# Refs of workbench: main(A) baz(A) next(A)
133
135
# git-push : main(A) NULL (B) baz(A) next(A)
134
- test_expect_success " porcelain output of successful git-push ($PROTOCOL )" '
135
- (
136
- cd workbench &&
137
- git update-ref refs/heads/main $A &&
138
- git update-ref refs/heads/baz $A &&
139
- git update-ref refs/heads/next $A &&
140
- git push --porcelain --force origin \
141
- main \
142
- :refs/heads/foo \
143
- $B:bar \
144
- baz \
145
- next
146
- ) >out &&
136
+ test_expect_success " .. git-push --porcelain --force ($PROTOCOL )" '
137
+ test_when_finished "setup_upstream \"$upstream\"" &&
138
+ git -C workbench push --porcelain --force origin \
139
+ main \
140
+ :refs/heads/foo \
141
+ $B:bar \
142
+ baz \
143
+ next >out &&
147
144
make_user_friendly_and_stable_output <out >actual &&
148
145
format_and_save_expect <<-EOF &&
149
146
> To <URL/of/upstream.git>
@@ -167,115 +164,103 @@ run_git_push_porcelain_output_test() {
167
164
test_cmp expect actual
168
165
'
169
166
170
- # Refs of upstream : main(A) bar(B) baz(A) next(A)
171
- # Refs of workbench: main(B) bar(A) baz(A) next(A)
172
- # git-push : main(B) bar(A) NULL next(A)
173
- test_expect_success " atomic push failed ($PROTOCOL )" '
174
- (
175
- cd workbench &&
176
- git update-ref refs/heads/main $B &&
177
- git update-ref refs/heads/bar $A &&
178
- test_must_fail git push --atomic --porcelain origin \
179
- main \
180
- bar \
181
- :baz \
182
- next
183
- ) >out &&
167
+ # Refs of upstream : main(B) foo(A) bar(A) baz(A)
168
+ # Refs of workbench: main(A) baz(A) next(A)
169
+ # git-push : main(A) NULL (B) baz(A) next(A)
170
+ test_expect_success " .. git push --porcelain --atomic ($PROTOCOL )" '
171
+ test_when_finished "setup_upstream \"$upstream\"" &&
172
+ test_must_fail git -C workbench push --porcelain --atomic origin \
173
+ main \
174
+ :refs/heads/foo \
175
+ $B:bar \
176
+ baz \
177
+ next >out &&
184
178
make_user_friendly_and_stable_output <out >actual &&
185
179
format_and_save_expect <<-EOF &&
186
- To <URL/of/upstream.git>
187
- > = refs/heads/next:refs/heads/next [up to date]
188
- > ! refs/heads/bar:refs/heads/bar [rejected] (non-fast-forward)
189
- > ! (delete):refs/heads/baz [rejected] (atomic push failed)
190
- > ! refs/heads/main:refs/heads/main [rejected] (atomic push failed)
191
- Done
180
+ > To <URL/of/upstream.git>
181
+ > = refs/heads/baz:refs/heads/baz [up to date]
182
+ > ! <COMMIT-B>:refs/heads/bar [rejected] (atomic push failed)
183
+ > ! (delete):refs/heads/foo [rejected] (atomic push failed)
184
+ > ! refs/heads/main:refs/heads/main [rejected] (non-fast-forward)
185
+ > ! refs/heads/next:refs/heads/next [rejected] (atomic push failed)
186
+ > Done
192
187
EOF
193
188
test_cmp expect actual &&
194
189
195
190
git -C "$upstream" show-ref >out &&
196
191
make_user_friendly_and_stable_output <out >actual &&
197
192
cat >expect <<-EOF &&
198
- <COMMIT-B > refs/heads/bar
193
+ <COMMIT-A > refs/heads/bar
199
194
<COMMIT-A> refs/heads/baz
200
- <COMMIT-A> refs/heads/main
201
- <COMMIT-A > refs/heads/next
195
+ <COMMIT-A> refs/heads/foo
196
+ <COMMIT-B > refs/heads/main
202
197
EOF
203
198
test_cmp expect actual
204
199
'
205
200
206
- test_expect_success " prepare pre-receive hook ($PROTOCOL )" '
207
- test_hook --setup -C "$upstream" pre-receive <<-EOF
208
- exit 1
201
+ # Refs of upstream : main(B) foo(A) bar(A) baz(A)
202
+ # Refs of workbench: main(A) baz(A) next(A)
203
+ # git-push : main(A) NULL (B) baz(A) next(A)
204
+ test_expect_success " .. pre-receive hook declined ($PROTOCOL )" '
205
+ test_when_finished "rm -f \"$upstream/hooks/pre-receive\" &&
206
+ setup_upstream \"$upstream\"" &&
207
+ test_hook --setup -C "$upstream" pre-receive <<-EOF &&
208
+ exit 1
209
209
EOF
210
- '
211
-
212
- # Refs of upstream : main(A) bar(B) baz(A) next(A)
213
- # Refs of workbench: main(B) bar(A) baz(A) next(A)
214
- # git-push : main(B) bar(A) NULL next(A)
215
- test_expect_success " pre-receive hook declined ($PROTOCOL )" '
216
- (
217
- cd workbench &&
218
- git update-ref refs/heads/main $B &&
219
- git update-ref refs/heads/bar $A &&
220
- test_must_fail git push --porcelain --force origin \
221
- main \
222
- bar \
223
- :baz \
224
- next
225
- ) >out &&
210
+ test_must_fail git -C workbench push --porcelain --force origin \
211
+ main \
212
+ :refs/heads/foo \
213
+ $B:bar \
214
+ baz \
215
+ next >out &&
226
216
make_user_friendly_and_stable_output <out >actual &&
227
217
format_and_save_expect <<-EOF &&
228
- To <URL/of/upstream.git>
229
- > = refs/heads/next :refs/heads/next [up to date]
230
- > ! refs/heads/bar :refs/heads/bar [remote rejected] (pre-receive hook declined)
231
- > ! :refs/heads/baz [remote rejected] (pre-receive hook declined)
218
+ > To <URL/of/upstream.git>
219
+ > = refs/heads/baz :refs/heads/baz [up to date]
220
+ > ! <COMMIT-B> :refs/heads/bar [remote rejected] (pre-receive hook declined)
221
+ > ! :refs/heads/foo [remote rejected] (pre-receive hook declined)
232
222
> ! refs/heads/main:refs/heads/main [remote rejected] (pre-receive hook declined)
233
- Done
223
+ > ! refs/heads/next:refs/heads/next [remote rejected] (pre-receive hook declined)
224
+ > Done
234
225
EOF
235
226
test_cmp expect actual &&
236
227
237
228
git -C "$upstream" show-ref >out &&
238
229
make_user_friendly_and_stable_output <out >actual &&
239
230
cat >expect <<-EOF &&
240
- <COMMIT-B > refs/heads/bar
231
+ <COMMIT-A > refs/heads/bar
241
232
<COMMIT-A> refs/heads/baz
242
- <COMMIT-A> refs/heads/main
243
- <COMMIT-A > refs/heads/next
233
+ <COMMIT-A> refs/heads/foo
234
+ <COMMIT-B > refs/heads/main
244
235
EOF
245
236
test_cmp expect actual
246
237
'
247
238
248
- test_expect_success " remove pre-receive hook ($PROTOCOL )" '
249
- rm "$upstream/hooks/pre-receive"
250
- '
251
-
252
- # Refs of upstream : main(A) bar(B) baz(A) next(A)
253
- # Refs of workbench: main(B) bar(A) baz(A) next(A)
254
- # git-push : main(B) bar(A) NULL next(A)
255
- test_expect_success " non-fastforward push ($PROTOCOL )" '
239
+ # Refs of upstream : main(B) foo(A) bar(A) baz(A)
240
+ # Refs of workbench: main(A) baz(A) next(A)
241
+ # git-push : main(A) next(A)
242
+ test_expect_success " .. non-fastforward push ($PROTOCOL )" '
256
243
(
257
244
cd workbench &&
258
245
test_must_fail git push --porcelain origin \
259
246
main \
260
- bar \
261
- :baz \
262
247
next
263
248
) >out &&
264
249
make_user_friendly_and_stable_output <out >actual &&
265
250
format_and_save_expect <<-EOF &&
266
- To <URL/of/upstream.git>
267
- > = refs/heads/next:refs/heads/next [up to date]
268
- > - :refs/heads/baz [deleted]
269
- > refs/heads/main:refs/heads/main <COMMIT-A>..<COMMIT-B>
270
- > ! refs/heads/bar:refs/heads/bar [rejected] (non-fast-forward)
271
- Done
251
+ > To <URL/of/upstream.git>
252
+ > * refs/heads/next:refs/heads/next [new branch]
253
+ > ! refs/heads/main:refs/heads/main [rejected] (non-fast-forward)
254
+ > Done
272
255
EOF
273
256
test_cmp expect actual &&
274
257
275
258
git -C "$upstream" show-ref >out &&
276
259
make_user_friendly_and_stable_output <out >actual &&
277
260
cat >expect <<-EOF &&
278
- <COMMIT-B> refs/heads/bar
261
+ <COMMIT-A> refs/heads/bar
262
+ <COMMIT-A> refs/heads/baz
263
+ <COMMIT-A> refs/heads/foo
279
264
<COMMIT-B> refs/heads/main
280
265
<COMMIT-A> refs/heads/next
281
266
EOF
0 commit comments