{"thread":{"id":"26057","subject":"[PATCH 07/14] t7800-difftool.sh: Fix a test failure on Cygwin","startedAt":"2010-12-14T18:27:48Z","lastAt":"2010-12-18T20:32:39Z","messageCount":6,"participants":["Ramsay Jones","Junio C Hamano","David Aguilar"],"isPatch":true,"patchVersion":1,"patchTotal":14},"messages":[{"id":"158069","messageId":"4D07B724.8000901@ramsay1.demon.co.uk","threadId":"26057","inReplyTo":null,"subject":"[PATCH 07/14] t7800-difftool.sh: Fix a test failure on Cygwin","fromName":"Ramsay Jones","fromEmail":"ramsay@ramsay1.demon.co.uk","sentAt":"2010-12-14T18:27:48Z","receivedAt":"2010-12-14T18:27:48Z","isPatch":true,"sender":{"key":"ramsay@ramsayjones.plus.com","avatar":"https://avatars.githubusercontent.com/u/33702710?v=4"},"body":"\nIn particular, test 14 'difftool last flag wins' fails. This is\ncaused by git-difftool.perl passing both GIT_DIFFTOOL_NO_PROMPT\n(='true') and GIT_DIFFTOOL_PROMPT (='true') to the difftool helper\nscript. Despite the appropriate key being deleted from the ENV\nhash, it seems that once a key has been set in the hash, it gets\npassed along to the system() call. (ie deleting the key does not\ndo the equivalent of unsetenv()).\n\nIn order to fix the problem, we keep track of the required prompt\nstate while processing the arguments, and then set the relevant\nENV hash key only once at the end.\n\nSigned-off-by: Ramsay Jones <ramsay@ramsay1.demon.co.uk>\n---\n git-difftool.perl |   12 ++++++++----\n 1 files changed, 8 insertions(+), 4 deletions(-)\n\ndiff --git a/git-difftool.perl b/git-difftool.perl\nindex e95e4ad..ced1615 100755\n--- a/git-difftool.perl\n+++ b/git-difftool.perl\n@@ -52,6 +52,7 @@ sub generate_command\n \tmy @command = (exe('git'), 'diff');\n \tmy $skip_next = 0;\n \tmy $idx = -1;\n+\tmy $prompt = '';\n \tfor my $arg (@ARGV) {\n \t\t$idx++;\n \t\tif ($skip_next) {\n@@ -89,13 +90,11 @@ sub generate_command\n \t\t\tnext;\n \t\t}\n \t\tif ($arg eq '-y' || $arg eq '--no-prompt') {\n-\t\t\t$ENV{GIT_DIFFTOOL_NO_PROMPT} = 'true';\n-\t\t\tdelete $ENV{GIT_DIFFTOOL_PROMPT};\n+\t\t\t$prompt = 'no';\n \t\t\tnext;\n \t\t}\n \t\tif ($arg eq '--prompt') {\n-\t\t\t$ENV{GIT_DIFFTOOL_PROMPT} = 'true';\n-\t\t\tdelete $ENV{GIT_DIFFTOOL_NO_PROMPT};\n+\t\t\t$prompt = 'yes';\n \t\t\tnext;\n \t\t}\n \t\tif ($arg eq '-h' || $arg eq '--help') {\n@@ -103,6 +102,11 @@ sub generate_command\n \t\t}\n \t\tpush @command, $arg;\n \t}\n+\tif ($prompt eq 'yes') {\n+\t\t$ENV{GIT_DIFFTOOL_PROMPT} = 'true';\n+\t} elsif ($prompt eq 'no') {\n+\t\t$ENV{GIT_DIFFTOOL_NO_PROMPT} = 'true';\n+\t}\n \treturn @command\n }\n \n-- \n1.7.3\n"},{"id":"158081","messageId":"7v39q0upw7.fsf@alter.siamese.dyndns.org","threadId":"26057","inReplyTo":"4D07B724.8000901@ramsay1.demon.co.uk","subject":"Re: [PATCH 07/14] t7800-difftool.sh: Fix a test failure on Cygwin","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2010-12-14T19:15:52Z","receivedAt":"2010-12-14T19:15:52Z","isPatch":true,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"This is not just \"test failure\" but can cause a failure in the real life\nfor people who want \"the last flag wins\" to work, no?\n\nI'll retitle the patch and queue it separately from other test fixes.\n\nThanks.\n"},{"id":"158231","messageId":"4D0A70E8.9030803@ramsay1.demon.co.uk","threadId":"26057","inReplyTo":"7v39q0upw7.fsf@alter.siamese.dyndns.org","subject":"Re: [PATCH 07/14] t7800-difftool.sh: Fix a test failure on Cygwin","fromName":"Ramsay Jones","fromEmail":"ramsay@ramsay1.demon.co.uk","sentAt":"2010-12-16T20:04:56Z","receivedAt":"2010-12-16T20:04:56Z","isPatch":true,"sender":{"key":"ramsay@ramsayjones.plus.com","avatar":"https://avatars.githubusercontent.com/u/33702710?v=4"},"body":"Junio C Hamano wrote:\n> This is not just \"test failure\" but can cause a failure in the real life\n> for people who want \"the last flag wins\" to work, no?\n\nYes, indeed. I was concentrating on fixing test-suite failures (and that\ncan mean you have to modify the test, the application or both) so...\n\n> I'll retitle the patch and queue it separately from other test fixes.\n\nThanks!\n\nATB,\nRamsay Jones\n"},{"id":"158253","messageId":"20101217023357.GA30083@gmail.com","threadId":"26057","inReplyTo":"4D07B724.8000901@ramsay1.demon.co.uk","subject":"Re: [PATCH 07/14] t7800-difftool.sh: Fix a test failure on Cygwin","fromName":"David Aguilar","fromEmail":"davvid@gmail.com","sentAt":"2010-12-17T02:33:59Z","receivedAt":"2010-12-17T02:33:59Z","isPatch":true,"sender":{"key":"davvid@gmail.com","avatar":"https://avatars.githubusercontent.com/u/13196?v=4"},"body":"On Tue, Dec 14, 2010 at 06:27:48PM +0000, Ramsay Jones wrote:\n> \n> In particular, test 14 'difftool last flag wins' fails. This is\n> caused by git-difftool.perl passing both GIT_DIFFTOOL_NO_PROMPT\n> (='true') and GIT_DIFFTOOL_PROMPT (='true') to the difftool helper\n> script. Despite the appropriate key being deleted from the ENV\n> hash, it seems that once a key has been set in the hash, it gets\n> passed along to the system() call. (ie deleting the key does not\n> do the equivalent of unsetenv()).\n> \n> In order to fix the problem, we keep track of the required prompt\n> state while processing the arguments, and then set the relevant\n> ENV hash key only once at the end.\n> \n> Signed-off-by: Ramsay Jones <ramsay@ramsay1.demon.co.uk>\n> ---\n>  git-difftool.perl |   12 ++++++++----\n>  1 files changed, 8 insertions(+), 4 deletions(-)\n> \n> diff --git a/git-difftool.perl b/git-difftool.perl\n> index e95e4ad..ced1615 100755\n> --- a/git-difftool.perl\n> +++ b/git-difftool.perl\n> @@ -52,6 +52,7 @@ sub generate_command\n>  \tmy @command = (exe('git'), 'diff');\n>  \tmy $skip_next = 0;\n>  \tmy $idx = -1;\n> +\tmy $prompt = '';\n\nWould it be simpler to set $prompt = 1 and then\nflip it to 0 when -y | or --no-prompt is supplied?\n\n\n\n>  \tfor my $arg (@ARGV) {\n>  \t\t$idx++;\n>  \t\tif ($skip_next) {\n> @@ -89,13 +90,11 @@ sub generate_command\n>  \t\t\tnext;\n>  \t\t}\n>  \t\tif ($arg eq '-y' || $arg eq '--no-prompt') {\n> -\t\t\t$ENV{GIT_DIFFTOOL_NO_PROMPT} = 'true';\n> -\t\t\tdelete $ENV{GIT_DIFFTOOL_PROMPT};\n> +\t\t\t$prompt = 'no';\n>  \t\t\tnext;\n>  \t\t}\n>  \t\tif ($arg eq '--prompt') {\n> -\t\t\t$ENV{GIT_DIFFTOOL_PROMPT} = 'true';\n> -\t\t\tdelete $ENV{GIT_DIFFTOOL_NO_PROMPT};\n> +\t\t\t$prompt = 'yes';\n>  \t\t\tnext;\n>  \t\t}\n>  \t\tif ($arg eq '-h' || $arg eq '--help') {\n> @@ -103,6 +102,11 @@ sub generate_command\n>  \t\t}\n>  \t\tpush @command, $arg;\n>  \t}\n> +\tif ($prompt eq 'yes') {\n\nThis would become:\n\n\tif ($prompt) {\n\t\t...\n\t}\n\telse {\n\t\t...\n\t}\n\n> +\t\t$ENV{GIT_DIFFTOOL_PROMPT} = 'true';\n> +\t} elsif ($prompt eq 'no') {\n> +\t\t$ENV{GIT_DIFFTOOL_NO_PROMPT} = 'true';\n> +\t}\n>  \treturn @command\n>  }\n>  \n> -- \n> 1.7.3\n> \n> \n\n-- \n\t\tDavid\n"},{"id":"158287","messageId":"7vwrn8i31n.fsf@alter.siamese.dyndns.org","threadId":"26057","inReplyTo":"20101217023357.GA30083@gmail.com","subject":"Re: [PATCH 07/14] t7800-difftool.sh: Fix a test failure on Cygwin","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2010-12-17T19:59:16Z","receivedAt":"2010-12-17T19:59:16Z","isPatch":true,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"David Aguilar <davvid@gmail.com> writes:\n\n>> diff --git a/git-difftool.perl b/git-difftool.perl\n>> index e95e4ad..ced1615 100755\n>> --- a/git-difftool.perl\n>> +++ b/git-difftool.perl\n>> @@ -52,6 +52,7 @@ sub generate_command\n>>  \tmy @command = (exe('git'), 'diff');\n>>  \tmy $skip_next = 0;\n>>  \tmy $idx = -1;\n>> +\tmy $prompt = '';\n>\n> Would it be simpler to set $prompt = 1 and then\n> flip it to 0 when -y | or --no-prompt is supplied?\n> ...\n>\n> This would become:\n>\n> \tif ($prompt) {\n> \t\t...\n> \t}\n> \telse {\n> \t\t...\n> \t}\n\nBut that is not what the patch does, is it?\n\nIsn't it more like initializing $prompt to undef and then the above\ncondition becomes:\n\n\tif (!defined $prompt) {\n        \t; # nothing\n        elsif ($prompt) {\n\t\tsetenv PROMPT true\n\t} else {\n\t\tsetenv NO_PROMPT true\n\t}\n\nno?\n"},{"id":"158344","messageId":"4D0D1A67.4090000@ramsay1.demon.co.uk","threadId":"26057","inReplyTo":"7vwrn8i31n.fsf@alter.siamese.dyndns.org","subject":"Re: [PATCH 07/14] t7800-difftool.sh: Fix a test failure on Cygwin","fromName":"Ramsay Jones","fromEmail":"ramsay@ramsay1.demon.co.uk","sentAt":"2010-12-18T20:32:39Z","receivedAt":"2010-12-18T20:32:39Z","isPatch":true,"sender":{"key":"ramsay@ramsayjones.plus.com","avatar":"https://avatars.githubusercontent.com/u/33702710?v=4"},"body":"Junio C Hamano wrote:\n> David Aguilar <davvid@gmail.com> writes:\n> \n>>> diff --git a/git-difftool.perl b/git-difftool.perl\n>>> index e95e4ad..ced1615 100755\n>>> --- a/git-difftool.perl\n>>> +++ b/git-difftool.perl\n>>> @@ -52,6 +52,7 @@ sub generate_command\n>>>  \tmy @command = (exe('git'), 'diff');\n>>>  \tmy $skip_next = 0;\n>>>  \tmy $idx = -1;\n>>> +\tmy $prompt = '';\n>> Would it be simpler to set $prompt = 1 and then\n>> flip it to 0 when -y | or --no-prompt is supplied?\n>> ...\n>>\n>> This would become:\n>>\n>> \tif ($prompt) {\n>> \t\t...\n>> \t}\n>> \telse {\n>> \t\t...\n>> \t}\n> \n> But that is not what the patch does, is it?\n> \n> Isn't it more like initializing $prompt to undef and then the above\n> condition becomes:\n> \n> \tif (!defined $prompt) {\n>         \t; # nothing\n>         elsif ($prompt) {\n> \t\tsetenv PROMPT true\n> \t} else {\n> \t\tsetenv NO_PROMPT true\n> \t}\n> \n> no?\n\nYes. :-P\nAt least that is what I was aiming for.\n\nIn particular, if none of -y, --no-prompt or --prompt is passed on\nthe command-line, I don't want to set either key in the hash.\n(Or, to put it another way, I don't want to change the behaviour\nin this case, where neither variable is set in the environment\nof the helper script)\n\nATB,\nRamsay Jones\n"}]}