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

Re: fatal output from git-show really wants a terminal

From
Junio C Hamano <gitster@pobox.com>
Date
Dec 15, 2008, 08:15 UTC
Message-ID
<7v3agpzwet.fsf@gitster.siamese.dyndns.org>
In-Reply-To
<7vr64eb9ha.fsf@gitster.siamese.dyndns.org>
Junio C Hamano <gitster@pobox.com> writes:
Show 27 quoted lines
> "Boyd Stephen Smith Jr." <bss03@volumehost.net> writes:
>
>>>  $ git log >foo.out
>>>
>>>and start a pager, which makes no sense.
>>
>> Good point, I'll try and consider that while I investgate the history of the 
>> issue.
>
> Isn't the issue about 61b8050 (sending errors to stdout under $PAGER,
> 2008-02-16)?  With that commit, we changed things so that when we send the
> standard output to the $PAGER, we dup stderr to the $PAGER as well,
> because otherwise any output to stderr will be wiped out by whatever the
> pager does and the user will not notice the breakage.  E.g.
>
> 	$ git log
>
> will just show reams of output, and you won't see any errors and warnings
> even if there were any encountered during the process.
>
> Unfortunately we did it unconditionally.  There is no reason to dup stderr
> to the $PAGER if the command line was:
>
> 	$ git log 2>error.log
>
> in which case you would want to view the normal output in your $PAGER and
> you are keeping the log of the error output in a separate file.

I haven't heard anything more about this, but if you were indeed discussing the change made by 61b8050, I think the fix should just be like this.

 pager.c |    3 ++-
 1 files changed, 2 insertions(+), 1 deletions(-)
diff --git c/pager.c w/pager.c
index aa0966c..f19ddbc 100644
--- c/pager.c
+++ w/pager.c
@@ -70,7 +70,8 @@ void setup_pager(void)
 
 	/* original process continues, but writes to the pipe */
 	dup2(pager_process.in, 1);
-	dup2(pager_process.in, 2);
+	if (isatty(2))
+		dup2(pager_process.in, 2);
 	close(pager_process.in);
 
 	/* this makes sure that the parent terminates after the pager */
Previous: Junio C HamanoNext: Junio C Hamano
Message 11 of 13 in “fatal output from git-show really wants a terminal”
  1. Tim OlsenDec 10, 2008
  2. Boyd Stephen Smith Jr.Dec 10, 2008
  3. Johannes SixtDec 10, 2008
  4. Tim OlsenDec 10, 2008
  5. Boyd Stephen Smith Jr.Dec 10, 2008
  6. Boyd Stephen Smith Jr.Dec 11, 2008
  7. Jeff KingDec 11, 2008
  8. Boyd Stephen Smith Jr.Dec 11, 2008
  9. Jeff KingDec 11, 2008
  10. Junio C HamanoDec 11, 2008
  11. Junio C HamanoDec 15, 2008
  12. Junio C HamanoDec 15, 2008
  13. Jeff KingDec 15, 2008

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.