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

Re: git push output goes into stderr

From
Jeff King <peff@peff.net>
Date
Sep 7, 2011, 21:57 UTC
Message-ID
<20110907215716.GJ13364@sigill.intra.peff.net>
In-Reply-To
<20110906074916.GC28490@ecki>
On Tue, Sep 06, 2011 at 09:49:16AM +0200, Clemens Buchacher wrote:
Show 12 quoted lines
> On Sun, Sep 04, 2011 at 05:57:53PM -0700, Junio C Hamano wrote:
> > Lynn Lin <lynn.xin.lin@gmail.com> writes:
> > 
> > > When I create a local branch and then push it to remote. I find that
> > > the output without error goes into stderr, is this expected?
> > 
> > Progress output are sent to the stderr stream.
> 
> But it's not only progress output that goes to stderr in case of
> git push. Even the summary written in tranport_print_push_status
> goes to stderr, unless we specify git push --porcelain. Can't we
> let that part of the output go to stdout unconditionally?
We could, though it makes more sense on stderr to me.

Stdout has always been about "the main program output" and stderr about diagnostic messages. With a program whose main function is to generate output (e.g., "git tag -l", it's very easy to know that the list of tags is the main program output (which you don't want to pollute with anything else), and any problems or even general chattiness goes to stderr.

But with a program whose main function is to perform an action, like "git push", I think there are really two ways to look at it:

  1. There is no main output; any progress or status update is just
     diagnostic chat, and should go to stderr.
  2. The main output is the status report; it goes to stdout, and
     progress updates go to stderr.

I think both are equally valid mental models, and both are consistent with the philosophy above. If we switch, I wouldn't be surprised to see somebody say "why is this going to stdout, it should be on stderr". In fact, I seem to recall that we've had this discussion before on the list.

-Peff
Previous: Clemens BuchacherNext: Sitaram Chamarty
Message 4 of 8 in “git push output goes into stderr”
  1. Lynn LinSep 4, 2011
  2. Junio C HamanoSep 5, 2011
  3. Clemens BuchacherSep 6, 2011
  4. Jeff KingSep 7, 2011
  5. Sitaram ChamartySep 8, 2011
  6. Jeff KingSep 8, 2011
  7. Sitaram ChamartySep 8, 2011
  8. Sitaram ChamartySep 5, 2011

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.