summaryrefslogtreecommitdiff
path: root/git-difftool.perl
diff options
context:
space:
mode:
authorJohn Keeping <john@keeping.me.uk>2013-05-17 19:26:08 +0100
committerJunio C Hamano <gitster@pobox.com>2013-05-17 11:46:53 -0700
commit1f197a1de497db8898c9920fab77533dab34a03c (patch)
tree84de54dd5e8c42b3351e515ad6ec2b1702e2557d /git-difftool.perl
parent31eb360b43ec351b97adcf67e07fb748da574aaa (diff)
downloadgit-1f197a1de497db8898c9920fab77533dab34a03c.tar.gz
difftool: fix dir-diff when file does not exist in working tree
Commit 02c5631 (difftool --dir-diff: symlink all files matching the working tree, 2013-03-14) does not handle the case where a file that is being compared does not exist in the working tree. Fix this by checking for existence explicitly before running git-hash-object. Reported-by: Kevin Bracey <kevin@bracey.fi> Signed-off-by: John Keeping <john@keeping.me.uk> Signed-off-by: Junio C Hamano <gitster@pobox.com>
Diffstat (limited to 'git-difftool.perl')
-rwxr-xr-xgit-difftool.perl6
1 files changed, 6 insertions, 0 deletions
diff --git a/git-difftool.perl b/git-difftool.perl
index 67802922cc..8a75205537 100755
--- a/git-difftool.perl
+++ b/git-difftool.perl
@@ -92,6 +92,12 @@ sub use_wt_file
return 0;
}
+ if (! -e "$workdir/$file") {
+ # If the file doesn't exist in the working tree, we cannot
+ # use it.
+ return (0, $null_sha1);
+ }
+
my $wt_sha1 = $repo->command_oneline('hash-object', "$workdir/$file");
my $use = ($sha1 eq $null_sha1) || ($sha1 eq $wt_sha1);
return ($use, $wt_sha1);