@matheusbsbs / matheus-bagliano / commits / d531174fe3
Fork 0

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 <ramsay@ramsay1.demon.co.uk> Signed-off-by: Junio C Hamano <gitster@pobox.com>

Ramsay Jones committed Dec 14, 2010 at 18:27 UTC d531174fe386af00755619d6a204db74a30954f8
1 file changed +8 -4
git-difftool.perl
+8 -4
@@ -52,6 +52,7 @@ sub generate_command
52 my @command = (exe('git'), 'diff');
53 my $skip_next = 0;
54 my $idx = -1;
55 + my $prompt = '';
56 for my $arg (@ARGV) {
57 $idx++;
58 if ($skip_next) {
@@ -89,13 +90,11 @@ sub generate_command
90 next;
91 }
92 if ($arg eq '-y' || $arg eq '--no-prompt') {
92 - $ENV{GIT_DIFFTOOL_NO_PROMPT} = 'true';
93 - delete $ENV{GIT_DIFFTOOL_PROMPT};
93 + $prompt = 'no';
94 next;
95 }
96 if ($arg eq '--prompt') {
97 - $ENV{GIT_DIFFTOOL_PROMPT} = 'true';
98 - delete $ENV{GIT_DIFFTOOL_NO_PROMPT};
97 + $prompt = 'yes';
98 next;
99 }
100 if ($arg eq '-h' || $arg eq '--help') {
@@ -103,6 +102,11 @@ sub generate_command
102 }
103 push @command, $arg;
104 }
105 + if ($prompt eq 'yes') {
106 + $ENV{GIT_DIFFTOOL_PROMPT} = 'true';
107 + } elsif ($prompt eq 'no') {
108 + $ENV{GIT_DIFFTOOL_NO_PROMPT} = 'true';
109 + }
110 return @command
111 }
112