Skip to content

Commit d531174

Browse files
Ramsay Jonesgitster
authored andcommitted
difftool: Fix failure on Cygwin
In particular, test 14 'difftool last flag wins' in t7800 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 <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent c6d059b commit d531174

File tree

1 file changed

+8
-4
lines changed

1 file changed

+8
-4
lines changed

git-difftool.perl

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,7 @@ sub generate_command
5252
my @command = (exe('git'), 'diff');
5353
my $skip_next = 0;
5454
my $idx = -1;
55+
my $prompt = '';
5556
for my $arg (@ARGV) {
5657
$idx++;
5758
if ($skip_next) {
@@ -89,20 +90,23 @@ sub generate_command
8990
next;
9091
}
9192
if ($arg eq '-y' || $arg eq '--no-prompt') {
92-
$ENV{GIT_DIFFTOOL_NO_PROMPT} = 'true';
93-
delete $ENV{GIT_DIFFTOOL_PROMPT};
93+
$prompt = 'no';
9494
next;
9595
}
9696
if ($arg eq '--prompt') {
97-
$ENV{GIT_DIFFTOOL_PROMPT} = 'true';
98-
delete $ENV{GIT_DIFFTOOL_NO_PROMPT};
97+
$prompt = 'yes';
9998
next;
10099
}
101100
if ($arg eq '-h' || $arg eq '--help') {
102101
usage();
103102
}
104103
push @command, $arg;
105104
}
105+
if ($prompt eq 'yes') {
106+
$ENV{GIT_DIFFTOOL_PROMPT} = 'true';
107+
} elsif ($prompt eq 'no') {
108+
$ENV{GIT_DIFFTOOL_NO_PROMPT} = 'true';
109+
}
106110
return @command
107111
}
108112

0 commit comments

Comments
 (0)