summaryrefslogtreecommitdiff
path: root/git-difftool.perl
diff options
context:
space:
mode:
authorDavid Aguilar <davvid@gmail.com>2012-07-24 20:14:23 -0700
committerJunio C Hamano <gitster@pobox.com>2012-07-25 09:41:54 -0700
commit283abb2c8abb3f40d8d0170ba45c2e45d40f8cdb (patch)
tree1403de59b477a9fe7ad6da7cf345b7988ade2ae3 /git-difftool.perl
parent7c7584b97096a168fe1236c84e5e12d7bee24476 (diff)
downloadgit-283abb2c8abb3f40d8d0170ba45c2e45d40f8cdb.tar.gz
difftool: Check all return codes from compare()
Handle the case where compare() is unable to read its inputs. Emit a warning so that the user knows that something went wrong. We may later want to restructure the code so that we can inhibit tempdir cleanup when this condition is reached. Signed-off-by: David Aguilar <davvid@gmail.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
Diffstat (limited to 'git-difftool.perl')
-rwxr-xr-xgit-difftool.perl11
1 files changed, 10 insertions, 1 deletions
diff --git a/git-difftool.perl b/git-difftool.perl
index 30574801be..92f4907bbc 100755
--- a/git-difftool.perl
+++ b/git-difftool.perl
@@ -370,7 +370,16 @@ sub dir_diff
# external tool did not replace the original link with a file.
for my $file (@worktree) {
next if $symlinks && -l "$b/$file";
- if (-f "$b/$file" && compare("$b/$file", "$workdir/$file")) {
+ next if ! -f "$b/$file";
+
+ my $diff = compare("$b/$file", "$workdir/$file");
+ if ($diff == 0) {
+ next;
+ } elsif ($diff == -1) {
+ my $errmsg = "warning: Could not compare ";
+ $errmsg += "'$b/$file' with '$workdir/$file'\n";
+ warn $errmsg;
+ } elsif ($diff == 1) {
copy("$b/$file", "$workdir/$file") or die $!;
my $mode = stat("$b/$file")->mode;
chmod($mode, "$workdir/$file") or die $!;