All of lore.kernel.org
 help / color / mirror / Atom feed
From: David Aguilar <davvid@gmail.com>
To: Ramsay Jones <ramsay@ramsay1.demon.co.uk>
Cc: Junio C Hamano <gitster@pobox.com>,
	GIT Mailing-list <git@vger.kernel.org>
Subject: Re: [PATCH 07/14] t7800-difftool.sh: Fix a test failure on Cygwin
Date: Thu, 16 Dec 2010 18:33:59 -0800	[thread overview]
Message-ID: <20101217023357.GA30083@gmail.com> (raw)
In-Reply-To: <4D07B724.8000901@ramsay1.demon.co.uk>

On Tue, Dec 14, 2010 at 06:27:48PM +0000, Ramsay Jones wrote:
> 
> In particular, test 14 'difftool last flag wins' fails. This is
> caused by git-difftool.perl passing both GIT_DIFFTOOL_NO_PROMPT
> (='true') and GIT_DIFFTOOL_PROMPT (='true') to the difftool helper
> script. Despite the appropriate key being deleted from the ENV
> hash, it seems that once a key has been set in the hash, it gets
> passed along to the system() call. (ie deleting the key does not
> do the equivalent of unsetenv()).
> 
> In order to fix the problem, we keep track of the required prompt
> state while processing the arguments, and then set the relevant
> ENV hash key only once at the end.
> 
> Signed-off-by: Ramsay Jones <ramsay@ramsay1.demon.co.uk>
> ---
>  git-difftool.perl |   12 ++++++++----
>  1 files changed, 8 insertions(+), 4 deletions(-)
> 
> diff --git a/git-difftool.perl b/git-difftool.perl
> index e95e4ad..ced1615 100755
> --- a/git-difftool.perl
> +++ b/git-difftool.perl
> @@ -52,6 +52,7 @@ sub generate_command
>  	my @command = (exe('git'), 'diff');
>  	my $skip_next = 0;
>  	my $idx = -1;
> +	my $prompt = '';

Would it be simpler to set $prompt = 1 and then
flip it to 0 when -y | or --no-prompt is supplied?



>  	for my $arg (@ARGV) {
>  		$idx++;
>  		if ($skip_next) {
> @@ -89,13 +90,11 @@ sub generate_command
>  			next;
>  		}
>  		if ($arg eq '-y' || $arg eq '--no-prompt') {
> -			$ENV{GIT_DIFFTOOL_NO_PROMPT} = 'true';
> -			delete $ENV{GIT_DIFFTOOL_PROMPT};
> +			$prompt = 'no';
>  			next;
>  		}
>  		if ($arg eq '--prompt') {
> -			$ENV{GIT_DIFFTOOL_PROMPT} = 'true';
> -			delete $ENV{GIT_DIFFTOOL_NO_PROMPT};
> +			$prompt = 'yes';
>  			next;
>  		}
>  		if ($arg eq '-h' || $arg eq '--help') {
> @@ -103,6 +102,11 @@ sub generate_command
>  		}
>  		push @command, $arg;
>  	}
> +	if ($prompt eq 'yes') {

This would become:

	if ($prompt) {
		...
	}
	else {
		...
	}

> +		$ENV{GIT_DIFFTOOL_PROMPT} = 'true';
> +	} elsif ($prompt eq 'no') {
> +		$ENV{GIT_DIFFTOOL_NO_PROMPT} = 'true';
> +	}
>  	return @command
>  }
>  
> -- 
> 1.7.3
> 
> 

-- 
		David

  parent reply	other threads:[~2010-12-17  2:20 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2010-12-14 18:27 [PATCH 07/14] t7800-difftool.sh: Fix a test failure on Cygwin Ramsay Jones
2010-12-14 19:15 ` Junio C Hamano
2010-12-16 20:04   ` Ramsay Jones
2010-12-17  2:33 ` David Aguilar [this message]
2010-12-17 19:59   ` Junio C Hamano
2010-12-18 20:32     ` Ramsay Jones

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20101217023357.GA30083@gmail.com \
    --to=davvid@gmail.com \
    --cc=git@vger.kernel.org \
    --cc=gitster@pobox.com \
    --cc=ramsay@ramsay1.demon.co.uk \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.