for_each_reflog_ent(): extract a helper to process a single entry
[gitweb.git] / git-difftool.perl
index ae1e0525d89181f8adbe288b62e107b8dadb8ca1..c0798540adee04cb7cfb6fd04ef3541a1fcbb762 100755 (executable)
@@ -15,6 +15,7 @@
 use warnings;
 use File::Basename qw(dirname);
 use File::Copy;
+use File::Compare;
 use File::Find;
 use File::stat;
 use File::Path qw(mkpath);
@@ -336,8 +337,10 @@ sub write_to_file
        # files were modified during the diff, then the changes
        # should be copied back to the working tree
        for my $file (@working_tree) {
-               copy("$b/$file", "$workdir/$file") or die $!;
-               chmod(stat("$b/$file")->mode, "$workdir/$file") or die $!;
+               if (-e "$b/$file" && compare("$b/$file", "$workdir/$file")) {
+                       copy("$b/$file", "$workdir/$file") or die $!;
+                       chmod(stat("$b/$file")->mode, "$workdir/$file") or die $!;
+               }
        }
 } else {
        if (defined($prompt)) {