Skip to content

Commit 124b519

Browse files
committed
pager: do not leak "GIT_PAGER_IN_USE" to the pager
Since 2e6c012 (setup_pager: set GIT_PAGER_IN_USE, 2011-08-17), we export GIT_PAGER_IN_USE so that a process that becomes the upstream of the spawned pager can still tell that we have spawned the pager and decide to do colored output even when its output no longer goes to a terminal (i.e. isatty(1)). But we forgot to clear it from the enviornment of the spawned pager. This is not a problem in a sane world, but if you have a handful of thousands Git users in your organization, somebody is bound to do strange things, e.g. typing "!<ENTER>" instead of 'q' to get control back from $LESS. GIT_PAGER_IN_USE is still set in that subshell spawned by "less", and all sorts of interesting things starts happening, e.g. "git diff | cat" starts coloring its output. We can clear the environment variable in the half of the fork that runs the pager to avoid the confusion. Signed-off-by: Junio C Hamano <[email protected]> Acked-by: Jeff King <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent a915459 commit 124b519

File tree

1 file changed

+1
-0
lines changed

1 file changed

+1
-0
lines changed

pager.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -78,6 +78,7 @@ void setup_pager(void)
7878
argv_array_push(&pager_process.env_array, "LESS=FRX");
7979
if (!getenv("LV"))
8080
argv_array_push(&pager_process.env_array, "LV=-c");
81+
argv_array_push(&pager_process.env_array, "GIT_PAGER_IN_USE");
8182
if (start_command(&pager_process))
8283
return;
8384

0 commit comments

Comments
 (0)