aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--pager.c8
-rwxr-xr-xt/t7006-pager.sh11
2 files changed, 12 insertions, 7 deletions
diff --git a/pager.c b/pager.c
index dac358f04..975955ba8 100644
--- a/pager.c
+++ b/pager.c
@@ -11,8 +11,6 @@
* something different on Windows.
*/
-static int spawned_pager;
-
#ifndef WIN32
static void pager_preexec(void)
{
@@ -78,7 +76,7 @@ void setup_pager(void)
if (!pager)
return;
- spawned_pager = 1; /* means we are emitting to terminal */
+ setenv("GIT_PAGER_IN_USE", "true", 1);
/* spawn the pager */
pager_argv[0] = pager;
@@ -109,10 +107,6 @@ void setup_pager(void)
int pager_in_use(void)
{
const char *env;
-
- if (spawned_pager)
- return 1;
-
env = getenv("GIT_PAGER_IN_USE");
return env ? git_config_bool("GIT_PAGER_IN_USE", env) : 0;
}
diff --git a/t/t7006-pager.sh b/t/t7006-pager.sh
index 2ac729f40..4884e1b40 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