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

[PATCH 4/4] git-push: add tests for git push --porcelain

From
Larry D'Anna <larry@elder-gods.org>
Date
Feb 27, 2010, 04:52 UTC
Message-ID
<cdb729b9b59138cd01b65138966daf45a95d3026.1267245870.git.larry@elder-gods.org>
In-Reply-To
<cover.1267245870.git.larry@elder-gods.org>

Verify that the output format is correct for successful, rejected, and flagrantly erroneous pushes.

Signed-off-by: Larry D'Anna <larry@elder-gods.org>
---
 t/t5516-fetch-push.sh |   50 +++++++++++++++++++++++++++++++++++++++++++++++++
 1 files changed, 50 insertions(+), 0 deletions(-)
diff --git a/t/t5516-fetch-push.sh b/t/t5516-fetch-push.sh
index 0f04b2e..11adb0b 100755
--- a/t/t5516-fetch-push.sh
+++ b/t/t5516-fetch-push.sh
@@ -660,4 +660,54 @@ test_expect_success 'push with branches containing #' '
 	git checkout master
 '
 
+test_expect_success 'push --porcelain' '
+	mk_empty &&
+	echo >.git/foo  "To testrepo" &&
+	echo >>.git/foo "*	refs/heads/master:refs/remotes/origin/master	[new branch]"  &&
+	echo >>.git/foo "Done" &&
+	git push >.git/bar --porcelain  testrepo refs/heads/master:refs/remotes/origin/master &&
+	(
+		cd testrepo &&
+		r=$(git show-ref -s --verify refs/remotes/origin/master) &&
+		test "z$r" = "z$the_commit" &&
+		test 1 = $(git for-each-ref refs/remotes/origin | wc -l)
+	) &&
+	diff -q .git/foo .git/bar
+'
+
+test_expect_success 'push --porcelain bad url' '
+	mk_empty &&
+	test_must_fail git push >.git/bar --porcelain asdfasdfasd refs/heads/master:refs/remotes/origin/master &&
+	test_must_fail grep -q Done .git/bar
+'
+
+test_expect_success 'push --porcelain rejected' '
+	mk_empty &&
+	git push testrepo refs/heads/master:refs/remotes/origin/master &&
+	(cd testrepo &&
+		git reset --hard origin/master^
+		git config receive.denyCurrentBranch true) &&
+
+	echo >.git/foo  "To testrepo"  &&
+	echo >>.git/foo "!	refs/heads/master:refs/heads/master	[remote rejected] (branch is currently checked out)" &&
+
+	test_must_fail git push >.git/bar --porcelain  testrepo refs/heads/master:refs/heads/master &&
+	diff -q .git/foo .git/bar
+'
+
+test_expect_success 'push --porcelain --dry-run rejected' '
+	mk_empty &&
+	git push testrepo refs/heads/master:refs/remotes/origin/master &&
+	(cd testrepo &&
+		git reset --hard origin/master
+		git config receive.denyCurrentBranch true) &&
+
+	echo >.git/foo  "To testrepo"  &&
+	echo >>.git/foo "!	refs/heads/master^:refs/heads/master	[rejected] (non-fast-forward)" &&
+	echo >>.git/foo "Done" &&
+
+	test_must_fail git push >.git/bar --porcelain  --dry-run testrepo refs/heads/master^:refs/heads/master &&
+	diff -q .git/foo .git/bar
+'
+
 test_done
-- 
1.7.0.rc2.40.g7d8aa
Previous: Tay Ray Chuan
Message 6 of 6 in “ld/push-porcelain”
  1. 0/4 ld/push-porcelainLarry D'Anna, Feb 27, 2010
  2. 1/4 git-push: fix an advice message so it goes to stderrLarry D'Anna, Feb 27, 2010
  3. 2/4 git-push: send "To <remoteurl>" messages to the standard output in --porcelain modeLarry D'Anna, Feb 27, 2010
  4. 3/4 git-push: make git push --porcelain print "Done"Larry D'Anna, Feb 27, 2010
  5. Tay Ray ChuanFeb 27, 2010
  6. 4/4 git-push: add tests for git push --porcelainLarry D'Anna, Feb 27, 2010

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.