Skip to content

Commit a833502

Browse files
committed
pager: do not dup2 stderr if it is already redirected
An earlier commit 61b8050 (sending errors to stdout under $PAGER, 2008-02-16) avoided losing the error messages that are sent to the standard error when $PAGER is in effect by dup2'ing fd 2 to the pager. his way, showing a tag object that points to a bad object: $ git show tag-foo would give the error message to the pager. However, it was not quite right if the user did: $ git show 2>error.log tag-foo i.e. use the pager but store the errors in a separate file. Signed-off-by: Junio C Hamano <[email protected]>
1 parent d2dadfe commit a833502

File tree

1 file changed

+2
-1
lines changed

1 file changed

+2
-1
lines changed

pager.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -102,7 +102,8 @@ void setup_pager(void)
102102

103103
/* original process continues, but writes to the pipe */
104104
dup2(pager_process.in, 1);
105-
dup2(pager_process.in, 2);
105+
if (isatty(2))
106+
dup2(pager_process.in, 2);
106107
close(pager_process.in);
107108

108109
/* this makes sure that the parent terminates after the pager */

0 commit comments

Comments
 (0)