From: David Aguilar Date: Wed, 25 Jul 2012 03:14:23 +0000 (-0700) Subject: difftool: Check all return codes from compare() X-Git-Tag: v1.8.0-rc0~129^2~6 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=283abb2c8abb3f40d8d0170ba45c2e45d40f8cdb;p=thirdparty%2Fgit.git 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 Signed-off-by: Junio C Hamano --- 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 $!;