@@ -132,6 +132,40 @@ run_git_push_porcelain_output_test() {
132132 ;;
133133 esac
134134
135+ # Refs of upstream : main(B) foo(A) bar(A) baz(A)
136+ # Refs of workbench: main(A) baz(A) next(A)
137+ # git-push : main(A) NULL (B) baz(A) next(A)
138+ test_expect_success " .. git-push --porcelain ($PROTOCOL )" '
139+ test_when_finished "setup_upstream \"$upstream\"" &&
140+ test_must_fail git -C workbench push --porcelain origin \
141+ main \
142+ :refs/heads/foo \
143+ $B:bar \
144+ baz \
145+ next >out &&
146+ make_user_friendly_and_stable_output <out >actual &&
147+ format_and_save_expect <<-EOF &&
148+ > To <URL/of/upstream.git>
149+ > = refs/heads/baz:refs/heads/baz [up to date]
150+ > <COMMIT-B>:refs/heads/bar <COMMIT-A>..<COMMIT-B>
151+ > - :refs/heads/foo [deleted]
152+ > * refs/heads/next:refs/heads/next [new branch]
153+ > ! refs/heads/main:refs/heads/main [rejected] (non-fast-forward)
154+ > Done
155+ EOF
156+ test_cmp expect actual &&
157+
158+ git -C "$upstream" show-ref >out &&
159+ make_user_friendly_and_stable_output <out >actual &&
160+ cat >expect <<-EOF &&
161+ <COMMIT-B> refs/heads/bar
162+ <COMMIT-A> refs/heads/baz
163+ <COMMIT-B> refs/heads/main
164+ <COMMIT-A> refs/heads/next
165+ EOF
166+ test_cmp expect actual
167+ '
168+
135169 # Refs of upstream : main(B) foo(A) bar(A) baz(A)
136170 # Refs of workbench: main(A) baz(A) next(A)
137171 # git-push : main(A) NULL (B) baz(A) next(A)
@@ -242,6 +276,7 @@ run_git_push_porcelain_output_test() {
242276 # Refs of workbench: main(A) baz(A) next(A)
243277 # git-push : main(A) next(A)
244278 test_expect_success " .. non-fastforward push ($PROTOCOL )" '
279+ test_when_finished "setup_upstream \"$upstream\"" &&
245280 (
246281 cd workbench &&
247282 test_must_fail git push --porcelain origin \
@@ -268,6 +303,39 @@ run_git_push_porcelain_output_test() {
268303 EOF
269304 test_cmp expect actual
270305 '
306+
307+ # Refs of upstream : main(B) foo(A) bar(A) baz(A)
308+ # Refs of workbench: main(A) baz(A) next(A)
309+ # git-push : main(A) NULL (B) baz(A) next(A)
310+ test_expect_success " .. git push --porcelain --atomic --force ($PROTOCOL )" '
311+ git -C workbench push --porcelain --atomic --force origin \
312+ main \
313+ :refs/heads/foo \
314+ $B:bar \
315+ baz \
316+ next >out &&
317+ make_user_friendly_and_stable_output <out >actual &&
318+ format_and_save_expect <<-EOF &&
319+ > To <URL/of/upstream.git>
320+ > = refs/heads/baz:refs/heads/baz [up to date]
321+ > <COMMIT-B>:refs/heads/bar <COMMIT-A>..<COMMIT-B>
322+ > - :refs/heads/foo [deleted]
323+ > + refs/heads/main:refs/heads/main <COMMIT-B>...<COMMIT-A> (forced update)
324+ > * refs/heads/next:refs/heads/next [new branch]
325+ > Done
326+ EOF
327+ test_cmp expect actual &&
328+
329+ git -C "$upstream" show-ref >out &&
330+ make_user_friendly_and_stable_output <out >actual &&
331+ cat >expect <<-EOF &&
332+ <COMMIT-B> refs/heads/bar
333+ <COMMIT-A> refs/heads/baz
334+ <COMMIT-A> refs/heads/main
335+ <COMMIT-A> refs/heads/next
336+ EOF
337+ test_cmp expect actual
338+ '
271339}
272340
273341setup_upstream_and_workbench upstream.git
0 commit comments