Re: [PATCH 6/7] Git.pm: introduce environment variable GIT_TEST_PRETEND_TTY
- From
- Phillip Wood <phillip.wood@talktalk.net>
- Date
- Jan 14, 2019, 11:13 UTC
- Message-ID
- <fd6bab55-871c-4f4d-84e9-98bfe5d54f23@talktalk.net>
- In-Reply-To
- <86d85face8ba543fb4a03adbc42dc930ee318f74.1545307756.git.gitgitgadget@gmail.com>
Hi Salvica/Johannes
On 20/12/2018 12:09, Slavica Djukic via GitGitGadget wrote:
Show 6 quoted lines
> From: Slavica Djukic <slawica92@hotmail.com> > > 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.
I normally use GIT_PAGER_IN_USE=1 to force colored output, is there some reason that does not work here?
Best Wishes
Phillip
Show 36 quoted lines
>
> Signed-off-by: Slavica Djukic <slawica92@hotmail.com>
> ---
> 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');
>