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

Re: Fix 'git log' early pager startup error case

From
Junio C Hamano <gitster@pobox.com>
Date
Aug 25, 2010, 19:16 UTC
Message-ID
<7vtymiqz9c.fsf@alter.siamese.dyndns.org>
In-Reply-To
<alpine.LFD.2.00.1008241029530.1046@i5.linux-foundation.org>
Linus Torvalds <torvalds@linux-foundation.org> writes:
> We start the pager too early for several git commands, which results in 
> the errors sometimes going to the pager rather than show up as errors.
Hmm...
  $ LESS=-S git log --prettty; echo $?
  ... less shows the message and then the message is lost from the screen
  128
  $ git --no-pager log --prettty; echo $?
  fatal: unrecognized argument: --prettty
  128
  $ LESS=-S git log --prettty 2>err; echo $?; cat err
  ... less shows empty and then screen snaps back
  128
  fatal: unrecognized argument: --prettty
  $ git --no-pager log --prettty 2>err; echo $?; cat err
  128
  fatal: unrecognized argument: --prettty

In all cases when the user wants to see the error message s/he sees it, when the user wants to capture it to a file, it is captured, and the correct error status is returned to the calling shell.

The only difference is that after the user dismisses the pager, the error message is lost. I am not sure if that is a problem, though.

Ah, there actually is another difference.  This is broken:
  $ PAGER=no-such-pager git log --prettty; echo $?
  ... nothing is shown here ...
  128
and with yours:
  $ PAGER=no-such-pager ./git log --prettty; echo $?
  fatal: unrecognized argument: --prettty
  128
Thanks.
Previous: Eric BlakeNext: Linus Torvalds
Message 8 of 9 in “Fix 'git log' early pager startup error case”
  1. Linus TorvaldsAug 24, 2010
  2. Jonathan NiederAug 25, 2010
  3. Johannes SixtAug 25, 2010
  4. Eric BlakeAug 25, 2010
  5. setting working dir in posix_spawn() (Re: Fix 'git log' early pager startup error case)Jonathan Nieder, Aug 26, 2010
  6. Joshua JuranAug 26, 2010
  7. Eric BlakeAug 26, 2010
  8. Junio C HamanoAug 25, 2010
  9. Linus TorvaldsAug 25, 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.