git/list[1] front-page[2] threads[3] people[4] search[5] about
 

[PATCH v3 4/8] t5548: add new porcelain test cases

From
Jiang Xin <worldhello.net@gmail.com>
Date
Dec 10, 2024, 11:36 UTC
Message-ID
<26248735e1b81df8d34cb692ddd9d5fb55e22329.1733830410.git.zhiyou.jx@alibaba-inc.com>
In-Reply-To
<cover.1733830410.git.zhiyou.jx@alibaba-inc.com>
From: Jiang Xin <zhiyou.jx@alibaba-inc.com>
Change order of test cases and add new test cases:
 - git push --porcelain                  # failed: non-fast-forward
 - git push --porcelain --force
 - git push --porcelain --atomic         # failed: non-fast-forward
 - git push --porcelain --atomic --force
 - git push --porcelain --force          # failed: pre-receive declined
Signed-off-by: Jiang Xin <zhiyou.jx@alibaba-inc.com>
---
 t/t5548-push-porcelain.sh | 90 ++++++++++++++++++++++++++++-----------
 1 file changed, 65 insertions(+), 25 deletions(-)
diff --git a/t/t5548-push-porcelain.sh b/t/t5548-push-porcelain.sh
index ededd8edb9..799f6066a3 100755
--- a/t/t5548-push-porcelain.sh
+++ b/t/t5548-push-porcelain.sh
@@ -4,6 +4,9 @@
 #
 test_description='Test git push porcelain output'
 
+GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME=main
+export GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME
+
 . ./test-lib.sh
 
 # Create commits in <repo> and assign each commit's oid to shell variables
@@ -132,6 +135,40 @@ run_git_push_porcelain_output_test() {
 		;;
 	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 workbench: main(A)                  baz(A)  next(A)
 	# git-push         : main(A)  NULL    (B)     baz(A)  next(A)
@@ -203,13 +240,9 @@ run_git_push_porcelain_output_test() {
 	# 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 ".. pre-receive hook declined ($PROTOCOL)" '
-		test_when_finished "rm -f \"$upstream/hooks/pre-receive\" &&
-			setup_upstream \"$upstream\"" &&
-		test_hook --setup -C "$upstream" pre-receive <<-EOF &&
-			exit 1
-		EOF
-		test_must_fail git -C workbench push --porcelain --force origin \
+	test_expect_success ".. git push --porcelain --atomic --force ($PROTOCOL)" '
+		test_when_finished "setup_upstream \"$upstream\"" &&
+		git -C workbench push --porcelain --atomic --force origin \
 			main \
 			:refs/heads/foo \
 			$B:bar \
@@ -219,10 +252,10 @@ run_git_push_porcelain_output_test() {
 		format_and_save_expect <<-EOF &&
 		> To <URL/of/upstream.git>
 		> =	refs/heads/baz:refs/heads/baz	[up to date]
-		> !	<COMMIT-B>:refs/heads/bar	[remote rejected] (pre-receive hook declined)
-		> !	:refs/heads/foo	[remote rejected] (pre-receive hook declined)
-		> !	refs/heads/main:refs/heads/main	[remote rejected] (pre-receive hook declined)
-		> !	refs/heads/next:refs/heads/next	[remote rejected] (pre-receive hook declined)
+		>  	<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 &&
@@ -230,29 +263,37 @@ run_git_push_porcelain_output_test() {
 		git -C "$upstream" show-ref >out &&
 		make_user_friendly_and_stable_output <out >actual &&
 		cat >expect <<-EOF &&
-		<COMMIT-A> refs/heads/bar
+		<COMMIT-B> refs/heads/bar
 		<COMMIT-A> refs/heads/baz
-		<COMMIT-A> refs/heads/foo
-		<COMMIT-B> refs/heads/main
+		<COMMIT-A> 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 workbench: main(A)                  baz(A)  next(A)
-	# git-push         : main(A)                          next(A)
-	test_expect_success ".. non-fastforward push ($PROTOCOL)" '
-		(
-			cd workbench &&
-			test_must_fail git push --porcelain origin \
-				main \
-				next
-		) >out &&
+	# git-push         : main(A)  NULL    (B)     baz(A)  next(A)
+	test_expect_success ".. pre-receive hook declined ($PROTOCOL)" '
+		test_when_finished "rm -f \"$upstream/hooks/pre-receive\" &&
+			setup_upstream \"$upstream\"" &&
+		test_hook --setup -C "$upstream" pre-receive <<-EOF &&
+			exit 1
+		EOF
+		test_must_fail git -C workbench push --porcelain --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/next:refs/heads/next	[new branch]
-		> !	refs/heads/main:refs/heads/main	[rejected] (non-fast-forward)
+		> =	refs/heads/baz:refs/heads/baz	[up to date]
+		> !	<COMMIT-B>:refs/heads/bar	[remote rejected] (pre-receive hook declined)
+		> !	:refs/heads/foo	[remote rejected] (pre-receive hook declined)
+		> !	refs/heads/main:refs/heads/main	[remote rejected] (pre-receive hook declined)
+		> !	refs/heads/next:refs/heads/next	[remote rejected] (pre-receive hook declined)
 		> Done
 		EOF
 		test_cmp expect actual &&
@@ -264,7 +305,6 @@ run_git_push_porcelain_output_test() {
 		<COMMIT-A> refs/heads/baz
 		<COMMIT-A> refs/heads/foo
 		<COMMIT-B> refs/heads/main
-		<COMMIT-A> refs/heads/next
 		EOF
 		test_cmp expect actual
 	'
-- 
2.47.0.rc1.21.g81e7bd6151
Previous: Jiang XinNext: Jiang Xin
Message 21 of 54 in “transport: don't ignore git-receive-pack(1) exit code on atomic push”
  1. 0/2 transport: don't ignore git-receive-pack(1) exit code on atomic pushPatrick Steinhardt, Nov 13, 2024
  2. 1/2 t5504: modernize test by moving heredocs into test bodiesPatrick Steinhardt, Nov 13, 2024
  3. 2/2 transport: don't ignore git-receive-pack(1) exit code on atomic pushPatrick Steinhardt, Nov 13, 2024
  4. Jiang XinNov 14, 2024
  5. 0/6 fix behaviors of git-push --porcelainJiang Xin, Nov 14, 2024
  6. 1/6 t5548: new test cases for push --porcelain and --dry-runJiang Xin, Nov 14, 2024
  7. Patrick SteinhardtNov 25, 2024
  8. Jiang XinDec 3, 2024
  9. 2/6 push: fix the behavior of the Done message for porcelainJiang Xin, Nov 14, 2024
  10. Patrick SteinhardtNov 25, 2024
  11. 3/6 t5504: modernize test by moving heredocs into test bodiesJiang Xin, Nov 14, 2024
  12. 4/6 t5543: atomic push reports exit code failureJiang Xin, Nov 14, 2024
  13. 5/6 push: only ignore finish_connect() for dry-run modeJiang Xin, Nov 14, 2024
  14. Patrick SteinhardtNov 25, 2024
  15. 6/6 push: not send push-options to server with --dry-runJiang Xin, Nov 14, 2024
  16. Patrick SteinhardtNov 25, 2024
  17. 0/8 fix behaviors of git-push --porcelainJiang Xin, Dec 10, 2024
  18. 1/8 t5504: modernize test by moving heredocs into test bodiesJiang Xin, Dec 10, 2024
  19. 2/8 t5548: refactor to reuse setup_upstream() functionJiang Xin, Dec 10, 2024
  20. 3/8 t5548: refactor test cases by resetting upstreamJiang Xin, Dec 10, 2024
  21. 4/8 t5548: add new porcelain test casesJiang Xin, Dec 10, 2024
  22. 5/8 t5548: add porcelain push test cases for dry-run modeJiang Xin, Dec 10, 2024
  23. Jiang XinDec 10, 2024
  24. 6/8 send-pack: new return code "ERROR_SEND_PACK_BAD_REF_STATUS"Jiang Xin, Dec 10, 2024
  25. Patrick SteinhardtDec 16, 2024
  26. 7/8 t5543: atomic push reports exit code failureJiang Xin, Dec 10, 2024
  27. 8/8 send-pack: gracefully close the connection for atomic pushJiang Xin, Dec 10, 2024
  28. Patrick SteinhardtDec 16, 2024
  29. Junio C HamanoNov 14, 2024
  30. Patrick SteinhardtNov 25, 2024
  31. 0/8 transport: don't ignore git-receive-pack(1) exit code on atomic pushPatrick Steinhardt, Jan 31, 2025
  32. 1/8 t5504: modernize test by moving heredocs into test bodiesPatrick Steinhardt, Jan 31, 2025
  33. Eric SunshineJan 31, 2025
  34. Junio C HamanoJan 31, 2025
  35. Patrick SteinhardtFeb 3, 2025
  36. 2/8 t5548: refactor to reuse setup_upstream() functionPatrick Steinhardt, Jan 31, 2025
  37. Eric SunshineJan 31, 2025
  38. 4/8 t5548: add new porcelain test casesPatrick Steinhardt, Jan 31, 2025
  39. Eric SunshineJan 31, 2025
  40. 5/8 t5548: add porcelain push test cases for dry-run modePatrick Steinhardt, Jan 31, 2025
  41. 3/8 t5548: refactor test cases by resetting upstreamPatrick Steinhardt, Jan 31, 2025
  42. 7/8 t5543: atomic push reports exit code failurePatrick Steinhardt, Jan 31, 2025
  43. 6/8 send-pack: new return code "ERROR_SEND_PACK_BAD_REF_STATUS"Patrick Steinhardt, Jan 31, 2025
  44. 8/8 send-pack: gracefully close the connection for atomic pushPatrick Steinhardt, Jan 31, 2025
  45. 0/8 transport: don't ignore git-receive-pack(1) exit code on atomic pushPatrick Steinhardt, Feb 3, 2025
  46. 1/8 t5504: modernize test by moving heredocs into test bodiesPatrick Steinhardt, Feb 3, 2025
  47. 2/8 t5548: refactor to reuse setup_upstream() functionPatrick Steinhardt, Feb 3, 2025
  48. 3/8 t5548: refactor test cases by resetting upstreamPatrick Steinhardt, Feb 3, 2025
  49. 4/8 t5548: add new porcelain test casesPatrick Steinhardt, Feb 3, 2025
  50. 5/8 t5548: add porcelain push test cases for dry-run modePatrick Steinhardt, Feb 3, 2025
  51. 6/8 send-pack: new return code "ERROR_SEND_PACK_BAD_REF_STATUS"Patrick Steinhardt, Feb 3, 2025
  52. 7/8 t5543: atomic push reports exit code failurePatrick Steinhardt, Feb 3, 2025
  53. 8/8 send-pack: gracefully close the connection for atomic pushPatrick Steinhardt, Feb 3, 2025
  54. Junio C HamanoFeb 3, 2025

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.