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

[PATCH 4/4] git-push: make git push --dry-run --porcelain exit with status 0 even if updates will be rejected

From
Larry D'Anna <larry@elder-gods.org>
Date
Feb 26, 2010, 19:50 UTC
Message-ID
<86338fdce80769f0a2d6dddc6436f8168f17d29d.1267211537.git.larry@elder-gods.org>
In-Reply-To
<cover.1267211537.git.larry@elder-gods.org>

The script calling git push --dry-run --porcelain can see clearly from the output that the updates will be rejected. However, it will probably need to distinguish this condition from the push failing for other reasons, such as the remote not being reachable.

Signed-off-by: Larry D'Anna <larry@elder-gods.org>
---
 builtin-send-pack.c |    4 ++++
 send-pack.h         |    1 +
 transport.c         |    4 +++-
 3 files changed, 8 insertions(+), 1 deletions(-)
diff --git a/builtin-send-pack.c b/builtin-send-pack.c
index 2183a47..2bf3d43 100644
--- a/builtin-send-pack.c
+++ b/builtin-send-pack.c
@@ -510,6 +510,10 @@ int send_pack(struct send_pack_args *args,
 
 	if (ret < 0)
 		return ret;
+
+	if (args->porcelain && args->dry_run)
+		return 0;
+
 	for (ref = remote_refs; ref; ref = ref->next) {
 		switch (ref->status) {
 		case REF_STATUS_NONE:
diff --git a/send-pack.h b/send-pack.h
index 28141ac..60b4ba6 100644
--- a/send-pack.h
+++ b/send-pack.h
@@ -4,6 +4,7 @@
 struct send_pack_args {
 	unsigned verbose:1,
 		quiet:1,
+		porcelain:1,
 		send_mirror:1,
 		force_update:1,
 		use_thin_pack:1,
diff --git a/transport.c b/transport.c
index 32885f7..8291621 100644
--- a/transport.c
+++ b/transport.c
@@ -791,6 +791,7 @@ static int git_transport_push(struct transport *transport, struct ref *remote_re
 	args.verbose = !!(flags & TRANSPORT_PUSH_VERBOSE);
 	args.quiet = !!(flags & TRANSPORT_PUSH_QUIET);
 	args.dry_run = !!(flags & TRANSPORT_PUSH_DRY_RUN);
+	args.porcelain = !!(flags & TRANSPORT_PUSH_PORCELAIN);
 
 	ret = send_pack(&args, data->fd, data->conn, remote_refs,
 			&data->extra_have);
@@ -1055,7 +1056,8 @@ int transport_push(struct transport *transport,
 		ret = transport->push_refs(transport, remote_refs, flags);
 		err = push_had_errors(remote_refs);
 
-		ret |= err;
+		if ( !(pretend && porcelain) )
+			ret |= err;
 
 		if (!quiet || err)
 			print_push_status(transport->url, remote_refs,
-- 
1.7.0.rc2.40.g7d8aa
Previous: Larry D'Anna
Message 6 of 6 in “ld/push-porcelain”
  1. 0/4 ld/push-porcelainLarry D'Anna, Feb 26, 2010
  2. 1/4 git-push: fix an error message so it goes to stderrLarry D'Anna, Feb 26, 2010
  3. 2/4 git-push: squelch advice message if in --porcelain modeLarry D'Anna, Feb 26, 2010
  4. Junio C HamanoFeb 26, 2010
  5. 3/4 git-push: send "To <remoteurl>" messages to the standard output in --porcelain modeLarry D'Anna, Feb 26, 2010
  6. 4/4 git-push: make git push --dry-run --porcelain exit with status 0 even if updates will be rejectedLarry D'Anna, Feb 26, 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.