t5548: add new porcelain test cases

Add two more test cases exercising git-push(1) with `--procelain`, one exercising a non-atomic and one exercising an atomic push. Based-on-patch-by: Jiang Xin <zhiyou.jx@alibaba-inc.com> Signed-off-by: Patrick Steinhardt <ps@pks.im> Signed-off-by: Junio C Hamano <gitster@pobox.com>

Patrick Steinhardt committed Feb 3, 2025 at 07:29 UTC 2329b6b461d8290f4706658ff080a888b74e9aef
1 file changed +68
t/t5548-push-porcelain.sh
+68
@@ -130,6 +130,40 @@ run_git_push_porcelain_output_test() {
130 ;;
131 esac
132
133 + # Refs of upstream : main(B) foo(A) bar(A) baz(A)
134 + # Refs of workbench: main(A) baz(A) next(A)
135 + # git-push : main(A) NULL (B) baz(A) next(A)
136 + test_expect_success ".. git-push --porcelain ($PROTOCOL)" '
137 + test_when_finished "setup_upstream \"$upstream\"" &&
138 + test_must_fail git -C workbench push --porcelain origin \
139 + main \
140 + :refs/heads/foo \
141 + $B:bar \
142 + baz \
143 + next >out &&
144 + make_user_friendly_and_stable_output <out >actual &&
145 + format_and_save_expect <<-\EOF &&
146 + > To <URL/of/upstream.git>
147 + > = refs/heads/baz:refs/heads/baz [up to date]
148 + > <COMMIT-B>:refs/heads/bar <COMMIT-A>..<COMMIT-B>
149 + > - :refs/heads/foo [deleted]
150 + > * refs/heads/next:refs/heads/next [new branch]
151 + > ! refs/heads/main:refs/heads/main [rejected] (non-fast-forward)
152 + > Done
153 + EOF
154 + test_cmp expect actual &&
155 +
156 + git -C "$upstream" show-ref >out &&
157 + make_user_friendly_and_stable_output <out >actual &&
158 + cat >expect <<-EOF &&
159 + <COMMIT-B> refs/heads/bar
160 + <COMMIT-A> refs/heads/baz
161 + <COMMIT-B> refs/heads/main
162 + <COMMIT-A> refs/heads/next
163 + EOF
164 + test_cmp expect actual
165 + '
166 +
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)
@@ -240,6 +274,7 @@ run_git_push_porcelain_output_test() {
274 # Refs of workbench: main(A) baz(A) next(A)
275 # git-push : main(A) next(A)
276 test_expect_success ".. non-fastforward push ($PROTOCOL)" '
277 + test_when_finished "setup_upstream \"$upstream\"" &&
278 (
279 cd workbench &&
280 test_must_fail git push --porcelain origin \
@@ -266,6 +301,39 @@ run_git_push_porcelain_output_test() {
301 EOF
302 test_cmp expect actual
303 '
304 +
305 + # Refs of upstream : main(B) foo(A) bar(A) baz(A)
306 + # Refs of workbench: main(A) baz(A) next(A)
307 + # git-push : main(A) NULL (B) baz(A) next(A)
308 + test_expect_success ".. git push --porcelain --atomic --force ($PROTOCOL)" '
309 + git -C workbench push --porcelain --atomic --force origin \
310 + main \
311 + :refs/heads/foo \
312 + $B:bar \
313 + baz \
314 + next >out &&
315 + make_user_friendly_and_stable_output <out >actual &&
316 + format_and_save_expect <<-\EOF &&
317 + > To <URL/of/upstream.git>
318 + > = refs/heads/baz:refs/heads/baz [up to date]
319 + > <COMMIT-B>:refs/heads/bar <COMMIT-A>..<COMMIT-B>
320 + > - :refs/heads/foo [deleted]
321 + > + refs/heads/main:refs/heads/main <COMMIT-B>...<COMMIT-A> (forced update)
322 + > * refs/heads/next:refs/heads/next [new branch]
323 + > Done
324 + EOF
325 + test_cmp expect actual &&
326 +
327 + git -C "$upstream" show-ref >out &&
328 + make_user_friendly_and_stable_output <out >actual &&
329 + cat >expect <<-EOF &&
330 + <COMMIT-B> refs/heads/bar
331 + <COMMIT-A> refs/heads/baz
332 + <COMMIT-A> refs/heads/main
333 + <COMMIT-A> refs/heads/next
334 + EOF
335 + test_cmp expect actual
336 + '
337 }
338
339 setup_upstream_and_workbench upstream.git