From: Slavica Djukic <slawica92@xxxxxxxxxxx> To enable testing the colored output on Windows, enable TTY by using environment variable GIT_TEST_PRETEND_TTY. This is the original idea by Johannes Schindelin. Signed-off-by: Slavica Djukic <slawica92@xxxxxxxxxxx> --- color.c | 4 ++++ perl/Git.pm | 2 +- 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/color.c b/color.c index ebb222ec33..4aa6cc3442 100644 --- a/color.c +++ b/color.c @@ -323,6 +323,10 @@ static int check_auto_color(int fd) { static int color_stderr_is_tty = -1; int *is_tty_p = fd == 1 ? &color_stdout_is_tty : &color_stderr_is_tty; + + if (git_env_bool("GIT_TEST_PRETEND_TTY", 0)) + return 1; + if (*is_tty_p < 0) *is_tty_p = isatty(fd); if (*is_tty_p || (fd == 1 && pager_in_use() && pager_use_color)) { diff --git a/perl/Git.pm b/perl/Git.pm index d856930b2e..51a1ce0617 100644 --- a/perl/Git.pm +++ b/perl/Git.pm @@ -757,7 +757,7 @@ and returns boolean (true for "use color", false for "do not use color"). sub get_colorbool { my ($self, $var) = @_; - my $stdout_to_tty = (-t STDOUT) ? "true" : "false"; + my $stdout_to_tty = $ENV{GIT_TEST_PRETEND_TTY} || (-t STDOUT) ? "true" : "false"; my $use_color = $self->command_oneline('config', '--get-colorbool', $var, $stdout_to_tty); return ($use_color eq 'true'); -- gitgitgadget