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.