From 2e6c012e10fd866eb3259de3a929e0296daabbaf Mon Sep 17 00:00:00 2001 From: Jeff King Date: Wed, 17 Aug 2011 22:02:29 -0700 Subject: setup_pager: set GIT_PAGER_IN_USE We have always set a global "spawned_pager" variable when we start the pager. This lets us make the auto-color decision later in the program as as "we are outputting to a terminal, or to a pager which can handle colors". Commit 6e9af86 added support for the GIT_PAGER_IN_USE environment variable. An external program calling git (e.g., git-svn) could set this variable to indicate that it had already started the pager, and that the decision about auto-coloring should take that into account. However, 6e9af86 failed to do the reverse, which is to tell external programs when git itself has started the pager. Thus a git command implemented as an external script that has the pager turned on (e.g., "git -p stash show") would not realize it was going to a pager, and would suppress colors. This patch remedies that; we always set GIT_PAGER_IN_USE when we start the pager, and the value is respected by both this program and any spawned children. Signed-off-by: Jeff King Signed-off-by: Junio C Hamano --- t/t7006-pager.sh | 11 +++++++++++ 1 file changed, 11 insertions(+) (limited to 't') diff --git a/t/t7006-pager.sh b/t/t7006-pager.sh index 2ac729f40c..4884e1b40c 100755 --- a/t/t7006-pager.sh +++ b/t/t7006-pager.sh @@ -181,6 +181,17 @@ test_expect_success 'color when writing to a file intended for a pager' ' colorful colorful.log ' +test_expect_success TTY 'colors are sent to pager for external commands' ' + test_config alias.externallog "!git log" && + test_config color.ui auto && + ( + TERM=vt100 && + export TERM && + test_terminal git -p externallog + ) && + colorful paginated.out +' + # Use this helper to make it easy for the caller of your # terminal-using function to specify whether it should fail. # If you write -- cgit v1.2.3