[prev in list] [next in list] [prev in thread] [next in thread]
List: git
Subject: Re: [PATCH 2/2] difftool: handle uninitialized variable on empty diff
From: Junio C Hamano <gitster () pobox ! com>
Date: 2012-06-28 20:00:40
Message-ID: 7v7gur5hqv.fsf () alter ! siamese ! dyndns ! org
[Download RAW message or body]
Tim Henigan <tim.henigan@gmail.com> writes:
> When 'difftool --dir-diff' finds no changes, it results in an
> uninitialized variable warning.
>
> Signed-off-by: Tim Henigan <tim.henigan@gmail.com>
> ---
> 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@vger.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
[prev in list] [next in list] [prev in thread] [next in thread]
Configure |
About |
News |
Add a list |
Sponsored by KoreLogic