git/list[1] front-page[2] threads[3] people[4] search[5] about
 

[PATCH] pager: do not leak "GIT_PAGER_IN_USE" to the pager

From
Junio C Hamano <gitster@pobox.com>
Date
Jul 3, 2015, 17:18 UTC
Message-ID
<xmqqk2uh5fd6.fsf@gitster.dls.corp.google.com>

Since 2e6c01e2, 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>
---
 * Arguably, "git diff | cat" that is colored is much minor problem
   than that the user keep using that subshell from pager without
   realizing.  The user may run more git commands that spawn a pager
   and do the "!<ENTER>" infinite times creating a deep process tree
   and then "logout" many number of times.
 pager.c | 1 +
 1 file changed, 1 insertion(+)
diff --git a/pager.c b/pager.c
index 98b2682..070dc11 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;
 
Next: Jeff King
Message 1 of 2 in “pager: do not leak "GIT_PAGER_IN_USE" to the pager”
  1. pager: do not leak "GIT_PAGER_IN_USE" to the pagerJunio C Hamano, Jul 3, 2015
  2. Jeff KingJul 3, 2015

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.