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

Re: [PATCH 2/3] silence human readable info messages going to stderr from git push --porcelain

From
Junio C Hamano <gitster@pobox.com>
Date
Feb 5, 2010, 20:20 UTC
Message-ID
<7v1vgz5ta7.fsf@alter.siamese.dyndns.org>
In-Reply-To
<1265398462-17316-2-git-send-email-larry@elder-gods.org>
Larry D'Anna <larry@elder-gods.org> writes:
> These messages are redundant information to a script that's calling git-push.

Redundant is not a reason for a change; unwanted would be. And some of the messages you are trying to squelch indeed look like unwanted ones, but not all of them.

> -	if (flags & TRANSPORT_PUSH_VERBOSE)
> +	if (flags & TRANSPORT_PUSH_VERBOSE && !(flags & TRANSPORT_PUSH_PORCELAIN))
>  		fprintf(stderr, "Pushing to %s\n", transport->url);

Why should you be forbidden to expect "--porcelain -v" to give you this message?

Show 9 quoted lines
> @@ -123,7 +123,7 @@ static int push_with_options(struct transport *transport, int flags)
>  	if (!err)
>  		return 0;
>  
> -	if (nonfastforward && advice_push_nonfastforward) {
> +	if (!(flags & TRANSPORT_PUSH_PORCELAIN) && nonfastforward && advice_push_nonfastforward) {
>  		fprintf(stderr, "To prevent you from losing history, non-fast-forward updates were rejected\n"
>  				"Merge the remote changes before pushing again.  See the 'Note about\n"
>  				"fast-forwards' section of 'git push --help' for details.\n");

This probably is a good change; the long lines are unsightly but that is a separate topic.

Show 11 quoted lines
> diff --git a/transport.c b/transport.c
> index 3846aac..f707c7b 100644
> --- a/transport.c
> +++ b/transport.c
> @@ -674,7 +674,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)
> +	if (!count && !porcelain)
>  		fprintf(stderr, "To %s\n", dest);
I don't think this is correct.

If you have more than one remote.there.pushURL, the calling Porcelain script of "git push --porcelain there" should be able to tell which destination the following report is about, and without this line you cannot tell.

I would understand if this change were to make the message go to the standard output when operating with --porcelain option, though.

Show 6 quoted lines
> @@ -1067,10 +1067,10 @@ int transport_push(struct transport *transport,
>  		if (!(flags & TRANSPORT_PUSH_DRY_RUN)) {
>  			struct ref *ref;
>  			for (ref = remote_refs; ref; ref = ref->next)
> -				update_tracking_ref(transport->remote, ref, verbose);
> +				update_tracking_ref(transport->remote, ref, verbose && !porcelain);
Again, why  should you be forbidden to expect "--porcelain -v" to work?
> -		if (!quiet && !ret && !refs_pushed(remote_refs))
> +		if (!quiet && !porcelain && !ret && !refs_pushed(remote_refs))
>  			fprintf(stderr, "Everything up-to-date\n");

This is a borderline. If you are truly up-to-date, the calling script won't get anything. It may be easier for Porcelain scripts to see this message on the standard output as an explicit succeses report instead.

Previous: Larry D'AnnaNext: Larry D'Anna
Message 5 of 14 in “fix an error message in git-push so it goes to stderr”
  1. fix an error message in git-push so it goes to stderrLarry D'Anna, Feb 5, 2010
  2. Jeff KingFeb 5, 2010
  3. 1/3 fix an error message in git-push so it goes to stderrLarry D'Anna, Feb 5, 2010
  4. 2/3 silence human readable info messages going to stderr from git push --porcelainLarry D'Anna, Feb 5, 2010
  5. Junio C HamanoFeb 5, 2010
  6. Larry D'AnnaFeb 5, 2010
  7. 3/3 make git push --dry-run --porcelain exit with status 0 even if updates will be rejectedLarry D'Anna, Feb 5, 2010
  8. Jeff KingFeb 5, 2010
  9. Larry D'AnnaFeb 5, 2010
  10. Jeff KingFeb 5, 2010
  11. Larry D'AnnaFeb 5, 2010
  12. Jeff KingFeb 5, 2010
  13. Larry D'AnnaFeb 5, 2010
  14. Jeff KingFeb 5, 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.