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

Re: [PATCH 3/4] git-push: make git push --porcelain print "Done"

From
Tay Ray Chuan <rctay89@gmail.com>
Date
Feb 27, 2010, 04:19 UTC
Message-ID
<be6fef0d1002262019j2088d20dp89f1587e3921a1ba@mail.gmail.com>
In-Reply-To
<04fc63d0f8114f0cd721bcf3dff1f108e30b5308.1267243044.git.larry@elder-gods.org>
Hi,
On Sat, Feb 27, 2010 at 11:59 AM, Larry D'Anna <larry@elder-gods.org> wrote:
Show 5 quoted lines
> diff --git a/transport.c b/transport.c
> index 32885f7..5b880d7 100644
> --- a/transport.c
> +++ b/transport.c
> [snip]
This hunk:
Show 9 quoted lines
> @@ -1055,8 +1056,6 @@ int transport_push(struct transport *transport,
>                ret = transport->push_refs(transport, remote_refs, flags);
>                err = push_had_errors(remote_refs);
>
> -               ret |= err;
> -
>                if (!quiet || err)
>                        print_push_status(transport->url, remote_refs,
>                                        verbose | porcelain, porcelain,
and this hunk:
Show 19 quoted lines
> @@ -1071,9 +1070,15 @@ int transport_push(struct transport *transport,
>                                update_tracking_ref(transport->remote, ref, verbose);
>                }
>
> -               if (!quiet && !ret && !refs_pushed(remote_refs))
> -                       fprintf(stderr, "Everything up-to-date\n");
> -               return ret;
> +
> +               if (porcelain) {
> +                       if (ret==0)
> +                               fprintf (stdout, "Done\n");
> +               } else
> +                       if (!quiet && !ret && !refs_pushed(remote_refs))
> +                               fprintf(stderr, "Everything up-to-date\n");
> +
> +               return ret | err;
>        }
>        return 1;
>  }

slightly changes the conditions under which "Everything up-to-date" is printed, since you did away with "ret |= err". I guess you can mitigate this by adding "!err" to the list of operands:

  if (!quiet && !ret && !err && !refs_pushed(remote_refs))
      ....
Even better, create yet another temporary variable:
  push_ret = transport->push_refs(transport, remote_refs, flags);
  err = push_had_errors(remote_refs);
  ret = push_ret | err;

That way, you can access transport->push_refs() status (what you want), without messing with the other parts of the code and their assumptions.

One last thing: could the if statements towards the end be "flattened"?
  if (porcelain && ret == 0)
      fprintf(stdout, "Done\n");
  else if (!quiet && !ret && !refs_pushed(remote_refs))
      fprintf(stderr, "Everything up-to-date\n");
(sorry about the lack of tabs, gmail doesn't let me type those easily.)
-- 
Cheers,
Ray Chuan
Previous: Larry D'AnnaNext: Larry D'Anna
Message 5 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.