Skip to content

Commit

Permalink
pager: do not dup2 stderr if it is already redirected
Browse files Browse the repository at this point in the history
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 <gitster@pobox.com>
  • Loading branch information
Junio C Hamano committed Dec 15, 2008
1 parent d2dadfe commit a833502
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion pager.c
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,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 */
Expand Down

0 comments on commit a833502

Please sign in to comment.