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>
This commit is contained in:

committed by
Junio C Hamano

parent
bc0f5939a5
commit
2329b6b461
@ -130,6 +130,40 @@ run_git_push_porcelain_output_test() {
|
|||||||
;;
|
;;
|
||||||
esac
|
esac
|
||||||
|
|
||||||
|
# Refs of upstream : main(B) foo(A) bar(A) baz(A)
|
||||||
|
# Refs of workbench: main(A) baz(A) next(A)
|
||||||
|
# git-push : main(A) NULL (B) baz(A) next(A)
|
||||||
|
test_expect_success ".. git-push --porcelain ($PROTOCOL)" '
|
||||||
|
test_when_finished "setup_upstream \"$upstream\"" &&
|
||||||
|
test_must_fail git -C workbench push --porcelain origin \
|
||||||
|
main \
|
||||||
|
:refs/heads/foo \
|
||||||
|
$B:bar \
|
||||||
|
baz \
|
||||||
|
next >out &&
|
||||||
|
make_user_friendly_and_stable_output <out >actual &&
|
||||||
|
format_and_save_expect <<-\EOF &&
|
||||||
|
> To <URL/of/upstream.git>
|
||||||
|
> = refs/heads/baz:refs/heads/baz [up to date]
|
||||||
|
> <COMMIT-B>:refs/heads/bar <COMMIT-A>..<COMMIT-B>
|
||||||
|
> - :refs/heads/foo [deleted]
|
||||||
|
> * refs/heads/next:refs/heads/next [new branch]
|
||||||
|
> ! refs/heads/main:refs/heads/main [rejected] (non-fast-forward)
|
||||||
|
> Done
|
||||||
|
EOF
|
||||||
|
test_cmp expect actual &&
|
||||||
|
|
||||||
|
git -C "$upstream" show-ref >out &&
|
||||||
|
make_user_friendly_and_stable_output <out >actual &&
|
||||||
|
cat >expect <<-EOF &&
|
||||||
|
<COMMIT-B> refs/heads/bar
|
||||||
|
<COMMIT-A> refs/heads/baz
|
||||||
|
<COMMIT-B> refs/heads/main
|
||||||
|
<COMMIT-A> refs/heads/next
|
||||||
|
EOF
|
||||||
|
test_cmp expect actual
|
||||||
|
'
|
||||||
|
|
||||||
# Refs of upstream : main(B) foo(A) bar(A) baz(A)
|
# Refs of upstream : main(B) foo(A) bar(A) baz(A)
|
||||||
# Refs of workbench: main(A) baz(A) next(A)
|
# Refs of workbench: main(A) baz(A) next(A)
|
||||||
# git-push : main(A) NULL (B) baz(A) next(A)
|
# git-push : main(A) NULL (B) baz(A) next(A)
|
||||||
@ -240,6 +274,7 @@ run_git_push_porcelain_output_test() {
|
|||||||
# Refs of workbench: main(A) baz(A) next(A)
|
# Refs of workbench: main(A) baz(A) next(A)
|
||||||
# git-push : main(A) next(A)
|
# git-push : main(A) next(A)
|
||||||
test_expect_success ".. non-fastforward push ($PROTOCOL)" '
|
test_expect_success ".. non-fastforward push ($PROTOCOL)" '
|
||||||
|
test_when_finished "setup_upstream \"$upstream\"" &&
|
||||||
(
|
(
|
||||||
cd workbench &&
|
cd workbench &&
|
||||||
test_must_fail git push --porcelain origin \
|
test_must_fail git push --porcelain origin \
|
||||||
@ -266,6 +301,39 @@ run_git_push_porcelain_output_test() {
|
|||||||
EOF
|
EOF
|
||||||
test_cmp expect actual
|
test_cmp expect actual
|
||||||
'
|
'
|
||||||
|
|
||||||
|
# Refs of upstream : main(B) foo(A) bar(A) baz(A)
|
||||||
|
# Refs of workbench: main(A) baz(A) next(A)
|
||||||
|
# git-push : main(A) NULL (B) baz(A) next(A)
|
||||||
|
test_expect_success ".. git push --porcelain --atomic --force ($PROTOCOL)" '
|
||||||
|
git -C workbench push --porcelain --atomic --force origin \
|
||||||
|
main \
|
||||||
|
:refs/heads/foo \
|
||||||
|
$B:bar \
|
||||||
|
baz \
|
||||||
|
next >out &&
|
||||||
|
make_user_friendly_and_stable_output <out >actual &&
|
||||||
|
format_and_save_expect <<-\EOF &&
|
||||||
|
> To <URL/of/upstream.git>
|
||||||
|
> = refs/heads/baz:refs/heads/baz [up to date]
|
||||||
|
> <COMMIT-B>:refs/heads/bar <COMMIT-A>..<COMMIT-B>
|
||||||
|
> - :refs/heads/foo [deleted]
|
||||||
|
> + refs/heads/main:refs/heads/main <COMMIT-B>...<COMMIT-A> (forced update)
|
||||||
|
> * refs/heads/next:refs/heads/next [new branch]
|
||||||
|
> Done
|
||||||
|
EOF
|
||||||
|
test_cmp expect actual &&
|
||||||
|
|
||||||
|
git -C "$upstream" show-ref >out &&
|
||||||
|
make_user_friendly_and_stable_output <out >actual &&
|
||||||
|
cat >expect <<-EOF &&
|
||||||
|
<COMMIT-B> refs/heads/bar
|
||||||
|
<COMMIT-A> refs/heads/baz
|
||||||
|
<COMMIT-A> refs/heads/main
|
||||||
|
<COMMIT-A> refs/heads/next
|
||||||
|
EOF
|
||||||
|
test_cmp expect actual
|
||||||
|
'
|
||||||
}
|
}
|
||||||
|
|
||||||
setup_upstream_and_workbench upstream.git
|
setup_upstream_and_workbench upstream.git
|
||||||
|
Reference in New Issue
Block a user