]> git.ipfire.org Git - thirdparty/git.git/commit
pager: do not close fd 2 unnecessarily
authorRubén Justo <rjusto@gmail.com>
Thu, 25 Jul 2024 13:44:27 +0000 (15:44 +0200)
committerJunio C Hamano <gitster@pobox.com>
Thu, 25 Jul 2024 16:03:00 +0000 (09:03 -0700)
commitda9ef60c8f79b9af93a39fbd07dfc4e56a150d63
treec8d75e13ee907f12c842500a3819812779260222
parent7309be1fc52bc155b711a741e30a6e55ae9c3cdf
pager: do not close fd 2 unnecessarily

We send errors to the pager since 61b80509e3 (sending errors to stdout
under $PAGER, 2008-02-16).

In a8335024c2 (pager: do not dup2 stderr if it is already redirected,
2008-12-15) an exception was introduced to avoid redirecting stderr if
it is not connected to a terminal.

In such exceptional cases, the close(STDERR_FILENO) we're doing in
close_pager_fds, is unnecessary.

Furthermore, in a subsequent commit we're going to introduce changes
that will involve using close_pager_fds multiple times.

With this in mind, controlling when we want to close stderr, become
sensible.

Let's close(STDERR_FILENO) only when necessary, and pave the way for the
upcoming changes.

Signed-off-by: Rubén Justo <rjusto@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
pager.c