summary refs log tree commit diff
path: root/pager.c
diff options
context:
space:
mode:
authorJunio C Hamano <gitster@pobox.com>2015-07-03 10:18:45 -0700
committerJunio C Hamano <gitster@pobox.com>2015-07-03 18:07:21 -0700
commit124b51909dab82151dff8ae8fd3a588a8846c7ac (patch)
tree40c6a63fc39fbbae6d34a786691fc1863a813144 /pager.c
parenta915459097b72da9cc058172a54029352b684b0f (diff)
pager: do not leak "GIT_PAGER_IN_USE" to the pager
Since 2e6c012e (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 <gitster@pobox.com>
Acked-by: Jeff King <peff@peff.net>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
Diffstat (limited to 'pager.c')
-rw-r--r--pager.c1
1 files changed, 1 insertions, 0 deletions
diff --git a/pager.c b/pager.c
index f6e8c33192..d40288b3e4 100644
--- a/pager.c
+++ b/pager.c
@@ -78,6 +78,7 @@ void setup_pager(void)
 		argv_array_push(&pager_process.env_array, "LESS=FRX");
 	if (!getenv("LV"))
 		argv_array_push(&pager_process.env_array, "LV=-c");
+	argv_array_push(&pager_process.env_array, "GIT_PAGER_IN_USE");
 	if (start_command(&pager_process))
 		return;