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

Re: [PATCH v3 2/3] git-push: clean up some of the output from git push --porcelain

From
Junio C Hamano <gitster@pobox.com>
Date
Feb 8, 2010, 21:13 UTC
Message-ID
<7vvde7h1mn.fsf@alter.siamese.dyndns.org>
In-Reply-To
<7vtytrih7b.fsf@alter.siamese.dyndns.org>

I realize that I more-or-less repeated what I already said for the second round, so let's try a different approach.

How about replacing the three patches with something like this?
-- >8 --
Subject: push --porcelain: usability updates

"git push --porcelain" is meant for Porcelain scripts to read from; there is no reason to give advice messages meant for the user under that mode.

When reporting the update status, the name of the destination and "Everything up-to-date" message were shown to the standard error stream, but that is unfriendly when a Porcelain script is reading from us. Send them to the standard output to make it easier for them.

---
 builtin-push.c |    5 +++++
 transport.c    |    5 +++--
 2 files changed, 8 insertions(+), 2 deletions(-)
diff --git a/builtin-push.c b/builtin-push.c
index 5633f0a..f5082d8 100644
--- a/builtin-push.c
+++ b/builtin-push.c
@@ -226,6 +226,11 @@ int cmd_push(int argc, const char **argv, const char *prefix)
 	git_config(git_default_config, NULL);
 	argc = parse_options(argc, argv, prefix, options, push_usage, 0);
 
+	if (flags & TRANSPORT_PUSH_PORCELAIN) {
+		/* Do not give advice messages to Porcelain scripts */
+		advice_push_nonfastforward = 0;
+	}
+
 	if (deleterefs && (tags || (flags & (TRANSPORT_PUSH_ALL | TRANSPORT_PUSH_MIRROR))))
 		die("--delete is incompatible with --all, --mirror and --tags");
 	if (deleterefs && argc < 2)
diff --git a/transport.c b/transport.c
index 3846aac..0492934 100644
--- a/transport.c
+++ b/transport.c
@@ -675,7 +675,7 @@ static void print_ok_ref_status(struct ref *ref, int porcelain)
 static int print_one_push_status(struct ref *ref, const char *dest, int count, int porcelain)
 {
 	if (!count)
-		fprintf(stderr, "To %s\n", dest);
+		fprintf(porcelain ? stdout : stderr, "To %s\n", dest);
 
 	switch(ref->status) {
 	case REF_STATUS_NONE:
@@ -1071,7 +1071,8 @@ int transport_push(struct transport *transport,
 		}
 
 		if (!quiet && !ret && !refs_pushed(remote_refs))
-			fprintf(stderr, "Everything up-to-date\n");
+			fprintf(porcelain ? stdout : stderr,
+				"Everything up-to-date\n");
 		return ret;
 	}
 	return 1;
Previous: Junio C HamanoNext: Jeff King
Message 4 of 45 in “git-push: fix an error message so it goes to stderr”
  1. 1/3 git-push: fix an error message so it goes to stderrLarry D'Anna, Feb 8, 2010
  2. 2/3 git-push: clean up some of the output from git push --porcelainLarry D'Anna, Feb 8, 2010
  3. Junio C HamanoFeb 8, 2010
  4. Junio C HamanoFeb 8, 2010
  5. Jeff KingFeb 8, 2010
  6. Larry D'AnnaFeb 8, 2010
  7. Junio C HamanoFeb 8, 2010
  8. Larry D'AnnaFeb 8, 2010
  9. git-push: clean up some of the output from git pushLarry D'Anna, Feb 8, 2010
  10. Junio C HamanoFeb 8, 2010
  11. Larry D'AnnaFeb 8, 2010
  12. Junio C HamanoFeb 8, 2010
  13. git-push: fix the documentation to explain all the status flagsLarry D'Anna, Feb 8, 2010
  14. Junio C HamanoFeb 9, 2010
  15. Junio C HamanoFeb 9, 2010
  16. Junio C HamanoFeb 9, 2010
  17. Larry D'AnnaFeb 9, 2010
  18. Junio C HamanoFeb 9, 2010
  19. Larry D'AnnaFeb 9, 2010
  20. Larry D'AnnaFeb 9, 2010
  21. Junio C HamanoFeb 9, 2010
  22. Larry D'AnnaFeb 9, 2010
  23. Shawn O. PearceFeb 9, 2010
  24. Nicolas PitreFeb 9, 2010
  25. Shawn O. PearceFeb 9, 2010
  26. Junio C HamanoFeb 9, 2010
  27. Junio C HamanoFeb 9, 2010
  28. Shawn O. PearceFeb 10, 2010
  29. Larry D'AnnaFeb 9, 2010
  30. Jeff KingFeb 10, 2010
  31. Larry D'AnnaFeb 10, 2010
  32. Tay Ray ChuanFeb 10, 2010
  33. Junio C HamanoFeb 8, 2010
  34. Jeff KingFeb 10, 2010
  35. Junio C HamanoFeb 11, 2010
  36. Jeff KingFeb 12, 2010
  37. 3/3 git-push: make git push --dry-run --porcelain exit with status 0 even if updates will be rejectedLarry D'Anna, Feb 8, 2010
  38. Junio C HamanoFeb 8, 2010
  39. Larry D'AnnaFeb 8, 2010
  40. Junio C HamanoFeb 9, 2010
  41. Larry D'AnnaFeb 10, 2010
  42. 4/4 git-push: make git push --dry-run --porcelain exit with status 0 even if updates will be rejectedLarry D'Anna, Feb 10, 2010
  43. Larry D'AnnaFeb 15, 2010
  44. Junio C HamanoFeb 15, 2010
  45. Junio C HamanoFeb 8, 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.