|
|
|
Re: [PATCH 2/2] difftool: handle uninitialized variable on empty diff | |
| [Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] |
|
Tim Henigan <tim.henigan@xxxxxxxxx> writes:
> When 'difftool --dir-diff' finds no changes, it results in an
> uninitialized variable warning.
>
> Signed-off-by: Tim Henigan <tim.henigan@xxxxxxxxx>
> ---
> git-difftool.perl | 2 +-
> 1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/git-difftool.perl b/git-difftool.perl
> index 679a56d..c94557d 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) if ((not defined($diffrtn)) or (length($diffrtn) == 0));
Wouldn't it be far more readable to say something like
if (!$diffrtn) {
exit(0);
}
instead, as "diff --raw" output, when not empty, cannot be a single
"0"?
By the way, I suspect that the use of command_oneline() here is
wrong. It uses '-z' so that it can handle whitespace characters in
pathnames sensibly (in other words, the output does not use LF as a
record separator), so pathnames with LF in them will be output
literally. Taking only the first line of the "diff -z" output would
mean that you will stop when you see the first pathname with LF in
it.
This is not a new problem with this patch, but came from your
7e0abce (difftool: teach difftool to handle directory diffs,
2012-04-23).
--
To unsubscribe from this list: send the line "unsubscribe git" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html
[Newbies FAQ] [Linux Kernel Development] [Free Online Dating] [Gcc Help] [IETF Annouce] [DCCP] [Netdev] [Networking] [Security] [V4L] [Bugtraq] [Free Online Dating] [Photo] [Yosemite] [MIPS Linux] [ARM Linux] [Linux Security] [Linux RAID] [Linux SCSI] [Fedora Users] [Linux Resources]