git.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Junio C Hamano <gitster@pobox.com>
To: David Aguilar <davvid@gmail.com>
Cc: git@vger.kernel.org
Subject: Re: [PATCH] difftool: Fix '--gui' when diff.guitool is unconfigured
Date: Sun, 28 Mar 2010 09:29:03 -0700	[thread overview]
Message-ID: <7v39zk5s1c.fsf@alter.siamese.dyndns.org> (raw)
In-Reply-To: <1269727089-9506-1-git-send-email-davvid@gmail.com> (David Aguilar's message of "Sat\, 27 Mar 2010 14\:58\:09 -0700")

David Aguilar <davvid@gmail.com> writes:

> When diff.guitool is unconfigured and "--gui" is specified
> git-difftool dies with the following error message:
>
> 	config diff.guitool: command returned error: 1
>
> Catch the error so that the "--gui" flag is a no-op when
> diff.guitool is unconfigured.
>
> Signed-off-by: David Aguilar <davvid@gmail.com>

Makes sense; thanks.

>
> This is probably 'maint' material.
>
>  git-difftool.perl   |   12 +++++++-----
>  t/t7800-difftool.sh |    9 +++++++++
>  2 files changed, 16 insertions(+), 5 deletions(-)
>
> diff --git a/git-difftool.perl b/git-difftool.perl
> index d975d07..adc42de 100755
> --- a/git-difftool.perl
> +++ b/git-difftool.perl
> @@ -78,11 +78,13 @@ sub generate_command
>  			next;
>  		}
>  		if ($arg eq '-g' || $arg eq '--gui') {
> -			my $tool = Git::command_oneline('config',
> -			                                'diff.guitool');
> -			if (length($tool)) {
> -				$ENV{GIT_DIFF_TOOL} = $tool;
> -			}
> +			eval {
> +				my $tool = Git::command_oneline('config',
> +				                                'diff.guitool');
> +				if (length($tool)) {
> +					$ENV{GIT_DIFF_TOOL} = $tool;
> +				}
> +			};
>  			next;
>  		}
>  		if ($arg eq '-y' || $arg eq '--no-prompt') {
> diff --git a/t/t7800-difftool.sh b/t/t7800-difftool.sh
> index 19c72f5..1de83ef 100755
> --- a/t/t7800-difftool.sh
> +++ b/t/t7800-difftool.sh
> @@ -92,6 +92,15 @@ test_expect_success 'difftool honors --gui' '
>  	restore_test_defaults
>  '
>  
> +test_expect_success 'difftool --gui works without configured diff.guitool' '
> +	git config diff.tool test-tool &&
> +
> +	diff=$(git difftool --no-prompt --gui branch) &&
> +	test "$diff" = "branch" &&
> +
> +	restore_test_defaults
> +'
> +
>  # Specify the diff tool using $GIT_DIFF_TOOL
>  test_expect_success 'GIT_DIFF_TOOL variable' '
>  	git config --unset diff.tool
> -- 
> 1.7.0.3.291.g5e4f6

      reply	other threads:[~2010-03-28 16:29 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2010-03-27 21:58 [PATCH] difftool: Fix '--gui' when diff.guitool is unconfigured David Aguilar
2010-03-28 16:29 ` Junio C Hamano [this message]

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=7v39zk5s1c.fsf@alter.siamese.dyndns.org \
    --to=gitster@pobox.com \
    --cc=davvid@gmail.com \
    --cc=git@vger.kernel.org \
    /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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).