# [PATCH] difftool: silence warning

3 messages from 2012-08-21 to 2012-08-21. Participants: Ross Lagerwall, David Aguilar.
Thread: https://gitlist.dev/t/31305

## Ross Lagerwall, 2012-08-21 06:59

Subject: [PATCH] difftool: silence warning
Message-ID: <1345532358-11742-1-git-send-email-rosslagerwall@gmail.com>
URL: https://gitlist.dev/e/1345532358-11742-1-git-send-email-rosslagerwall%40gmail.com

```
Silence a warning given when running git difftool --dir-diff and
there are no changes.
This is because command_oneline returns undef when the command has no
output, not ''.

Signed-off-by: Ross Lagerwall <rosslagerwall@gmail.com>
---
 git-difftool.perl | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/git-difftool.perl b/git-difftool.perl
index ae1e052..1cfcbb3 100755
--- a/git-difftool.perl
+++ b/git-difftool.perl
@@ -117,7 +117,7 @@ sub setup_dir_diff
 	# by Git->repository->command*.
 	my $diffrepo = Git->repository(Repository => $repo_path, WorkingCopy => $workdir);
 	my $diffrtn = $diffrepo->command_oneline('diff', '--raw', '--no-abbrev', '-z', @ARGV);
-	exit(0) if (length($diffrtn) == 0);
+	exit(0) unless defined($diffrtn);
 
 	# Setup temp directories
 	my $tmpdir = tempdir('git-diffall.XXXXX', CLEANUP => 1, TMPDIR => 1);
-- 
1.7.11.4

```

## David Aguilar, 2012-08-21 09:04

Subject: Re: [PATCH] difftool: silence warning
Message-ID: <CAJDDKr5W5YJoMEkX7_ax_pvwdibJ81LMzsM0Rnkn1=9=Nu25EA@mail.gmail.com>
URL: https://gitlist.dev/e/CAJDDKr5W5YJoMEkX7_ax_pvwdibJ81LMzsM0Rnkn1%3D9%3DNu25EA%40mail.gmail.com
In-Reply-To: <1345532358-11742-1-git-send-email-rosslagerwall@gmail.com>

```
On Mon, Aug 20, 2012 at 11:59 PM, Ross Lagerwall
<rosslagerwall@gmail.com> wrote:
> Silence a warning given when running git difftool --dir-diff and
> there are no changes.
> This is because command_oneline returns undef when the command has no
> output, not ''.
>
> Signed-off-by: Ross Lagerwall <rosslagerwall@gmail.com>

Thanks

This patch is obviously correct, but it won't apply in git's "next" branch.
Can you please prepare a patch based on the version in next?


A small question on Perl style for the list... is it better say this?

   exit(0) unless $diffrtn;

or is it better to explicitly check for undef using defined($diffrtn)
like was done in this patch? I would assume that explicit is preferred.


> ---
>  git-difftool.perl | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/git-difftool.perl b/git-difftool.perl
> index ae1e052..1cfcbb3 100755
> --- a/git-difftool.perl
> +++ b/git-difftool.perl
> @@ -117,7 +117,7 @@ sub setup_dir_diff
>         # by Git->repository->command*.
>         my $diffrepo = Git->repository(Repository => $repo_path, WorkingCopy => $workdir);
>         my $diffrtn = $diffrepo->command_oneline('diff', '--raw', '--no-abbrev', '-z', @ARGV);
> -       exit(0) if (length($diffrtn) == 0);
> +       exit(0) unless defined($diffrtn);
>
>         # Setup temp directories
>         my $tmpdir = tempdir('git-diffall.XXXXX', CLEANUP => 1, TMPDIR => 1);
> --
> 1.7.11.4
-- 
David

```

## Ross Lagerwall, 2012-08-21 09:42

Subject: Re: [PATCH] difftool: silence warning
Message-ID: <503357F6.2020907@gmail.com>
URL: https://gitlist.dev/e/503357F6.2020907%40gmail.com
In-Reply-To: <CAJDDKr5W5YJoMEkX7_ax_pvwdibJ81LMzsM0Rnkn1=9=Nu25EA@mail.gmail.com>

```
On 08/21/2012 11:04 AM, David Aguilar wrote:
> This patch is obviously correct, but it won't apply in git's "next" branch.
> Can you please prepare a patch based on the version in next?
> 
Sure.

> 
> A small question on Perl style for the list... is it better say this?
> 
>    exit(0) unless $diffrtn;
> 
> or is it better to explicitly check for undef using defined($diffrtn)
> like was done in this patch? I would assume that explicit is preferred.
> 

It seems like defined() is used throughout git-difftool so I just used that.

Regards
-- 
Ross Lagerwall


```
