1
0
Fork 0
mirror of https://github.com/git/git.git synced 2024-06-07 17:46:10 +02:00

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>
This commit is contained in:
Tim Henigan 2012-07-19 01:27:09 -07:00 committed by Junio C Hamano
parent 0ce2e396ee
commit 05df532655

View File

@ -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)) {