Re: [PATCH 6/7] Git.pm: introduce environment variable GIT_TEST_PRETEND_TTY

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Hi Salvica/Johannes

On 20/12/2018 12:09, Slavica Djukic via GitGitGadget wrote:
> 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.

I normally use GIT_PAGER_IN_USE=1 to force colored output, is there some
reason that does not work here?

Best Wishes

Phillip

> 
> 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');
> 




[Index of Archives]     [Linux Kernel Development]     [Gcc Help]     [IETF Annouce]     [DCCP]     [Netdev]     [Networking]     [Security]     [V4L]     [Bugtraq]     [Yosemite]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Linux SCSI]     [Fedora Users]

  Powered by Linux