{"thread":{"id":"23206","subject":"[PATCH] difftool: Fix '--gui' when diff.guitool is unconfigured","startedAt":"2010-03-27T21:58:09Z","lastAt":"2010-03-28T16:29:03Z","messageCount":2,"participants":["David Aguilar","Junio C Hamano"],"isPatch":true,"patchVersion":1,"patchTotal":null},"messages":[{"id":"137975","messageId":"1269727089-9506-1-git-send-email-davvid@gmail.com","threadId":"23206","inReplyTo":null,"subject":"[PATCH] difftool: Fix '--gui' when diff.guitool is unconfigured","fromName":"David Aguilar","fromEmail":"davvid@gmail.com","sentAt":"2010-03-27T21:58:09Z","receivedAt":"2010-03-27T21:58:09Z","isPatch":true,"sender":{"key":"davvid@gmail.com","avatar":"https://avatars.githubusercontent.com/u/13196?v=4"},"body":"When diff.guitool is unconfigured and \"--gui\" is specified\ngit-difftool dies with the following error message:\n\n\tconfig diff.guitool: command returned error: 1\n\nCatch the error so that the \"--gui\" flag is a no-op when\ndiff.guitool is unconfigured.\n\nSigned-off-by: David Aguilar <davvid@gmail.com>\n---\n\nThis is probably 'maint' material.\n\n git-difftool.perl   |   12 +++++++-----\n t/t7800-difftool.sh |    9 +++++++++\n 2 files changed, 16 insertions(+), 5 deletions(-)\n\ndiff --git a/git-difftool.perl b/git-difftool.perl\nindex d975d07..adc42de 100755\n--- a/git-difftool.perl\n+++ b/git-difftool.perl\n@@ -78,11 +78,13 @@ sub generate_command\n \t\t\tnext;\n \t\t}\n \t\tif ($arg eq '-g' || $arg eq '--gui') {\n-\t\t\tmy $tool = Git::command_oneline('config',\n-\t\t\t                                'diff.guitool');\n-\t\t\tif (length($tool)) {\n-\t\t\t\t$ENV{GIT_DIFF_TOOL} = $tool;\n-\t\t\t}\n+\t\t\teval {\n+\t\t\t\tmy $tool = Git::command_oneline('config',\n+\t\t\t\t                                'diff.guitool');\n+\t\t\t\tif (length($tool)) {\n+\t\t\t\t\t$ENV{GIT_DIFF_TOOL} = $tool;\n+\t\t\t\t}\n+\t\t\t};\n \t\t\tnext;\n \t\t}\n \t\tif ($arg eq '-y' || $arg eq '--no-prompt') {\ndiff --git a/t/t7800-difftool.sh b/t/t7800-difftool.sh\nindex 19c72f5..1de83ef 100755\n--- a/t/t7800-difftool.sh\n+++ b/t/t7800-difftool.sh\n@@ -92,6 +92,15 @@ test_expect_success 'difftool honors --gui' '\n \trestore_test_defaults\n '\n \n+test_expect_success 'difftool --gui works without configured diff.guitool' '\n+\tgit config diff.tool test-tool &&\n+\n+\tdiff=$(git difftool --no-prompt --gui branch) &&\n+\ttest \"$diff\" = \"branch\" &&\n+\n+\trestore_test_defaults\n+'\n+\n # Specify the diff tool using $GIT_DIFF_TOOL\n test_expect_success 'GIT_DIFF_TOOL variable' '\n \tgit config --unset diff.tool\n-- \n1.7.0.3.291.g5e4f6\n"},{"id":"138013","messageId":"7v39zk5s1c.fsf@alter.siamese.dyndns.org","threadId":"23206","inReplyTo":"1269727089-9506-1-git-send-email-davvid@gmail.com","subject":"Re: [PATCH] difftool: Fix '--gui' when diff.guitool is unconfigured","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2010-03-28T16:29:03Z","receivedAt":"2010-03-28T16:29:03Z","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> When diff.guitool is unconfigured and \"--gui\" is specified\n> git-difftool dies with the following error message:\n>\n> \tconfig diff.guitool: command returned error: 1\n>\n> Catch the error so that the \"--gui\" flag is a no-op when\n> diff.guitool is unconfigured.\n>\n> Signed-off-by: David Aguilar <davvid@gmail.com>\n\nMakes sense; thanks.\n\n>\n> This is probably 'maint' material.\n>\n>  git-difftool.perl   |   12 +++++++-----\n>  t/t7800-difftool.sh |    9 +++++++++\n>  2 files changed, 16 insertions(+), 5 deletions(-)\n>\n> diff --git a/git-difftool.perl b/git-difftool.perl\n> index d975d07..adc42de 100755\n> --- a/git-difftool.perl\n> +++ b/git-difftool.perl\n> @@ -78,11 +78,13 @@ sub generate_command\n>  \t\t\tnext;\n>  \t\t}\n>  \t\tif ($arg eq '-g' || $arg eq '--gui') {\n> -\t\t\tmy $tool = Git::command_oneline('config',\n> -\t\t\t                                'diff.guitool');\n> -\t\t\tif (length($tool)) {\n> -\t\t\t\t$ENV{GIT_DIFF_TOOL} = $tool;\n> -\t\t\t}\n> +\t\t\teval {\n> +\t\t\t\tmy $tool = Git::command_oneline('config',\n> +\t\t\t\t                                'diff.guitool');\n> +\t\t\t\tif (length($tool)) {\n> +\t\t\t\t\t$ENV{GIT_DIFF_TOOL} = $tool;\n> +\t\t\t\t}\n> +\t\t\t};\n>  \t\t\tnext;\n>  \t\t}\n>  \t\tif ($arg eq '-y' || $arg eq '--no-prompt') {\n> diff --git a/t/t7800-difftool.sh b/t/t7800-difftool.sh\n> index 19c72f5..1de83ef 100755\n> --- a/t/t7800-difftool.sh\n> +++ b/t/t7800-difftool.sh\n> @@ -92,6 +92,15 @@ test_expect_success 'difftool honors --gui' '\n>  \trestore_test_defaults\n>  '\n>  \n> +test_expect_success 'difftool --gui works without configured diff.guitool' '\n> +\tgit config diff.tool test-tool &&\n> +\n> +\tdiff=$(git difftool --no-prompt --gui branch) &&\n> +\ttest \"$diff\" = \"branch\" &&\n> +\n> +\trestore_test_defaults\n> +'\n> +\n>  # Specify the diff tool using $GIT_DIFF_TOOL\n>  test_expect_success 'GIT_DIFF_TOOL variable' '\n>  \tgit config --unset diff.tool\n> -- \n> 1.7.0.3.291.g5e4f6\n"}]}