difftool: only copy back files modified during directory diff
When 'difftool --dir-diff' is used to compare working tree files, it always copies files from the tmp dir back to the working tree when the diff tool is closed, even if the files were not modified by the diff tool. This causes the file timestamp to change. Files should only be copied from the tmp dir back to the working copy if they were actually modified. Signed-off-by: Tim Henigan <tim.henigan@gmail.com> Signed-off-by: David Aguilar <davvid@gmail.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
Tim Henigan committed
Jul 19, 2012 at 01:27 UTC
05df532655e14ba351b4ee8a0acd8f190ed0b745
1 file changed
+5
-2
git-difftool.perl
+5
-2
@@ -15,6 +15,7 @@ use strict;
15
use warnings;
16
use File::Basename qw(dirname);
17
use File::Copy;
18
+use File::Compare;
19
use File::Find;
20
use File::stat;
21
use File::Path qw(mkpath);
@@ -336,8 +337,10 @@ if (defined($dirdiff)) {
337
# files were modified during the diff, then the changes
338
# should be copied back to the working tree
339
for my $file (@working_tree) {
339
- copy("$b/$file", "$workdir/$file") or die $!;
340
- chmod(stat("$b/$file")->mode, "$workdir/$file") or die $!;
340
+ if (-e "$b/$file" && compare("$b/$file", "$workdir/$file")) {
341
+ copy("$b/$file", "$workdir/$file") or die $!;
342
+ chmod(stat("$b/$file")->mode, "$workdir/$file") or die $!;
343
+ }
344
}
345
} else {
346
if (defined($prompt)) {