Tim Henigan [off-list ref] writes:
quoted hunk
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 <redacted>
---
This patch must be applied after commit 304970d on next (diff-no-index:
exit(1) if 'diff --quiet <repo file> <external file>' finds changes).
because it relies on 'git diff --quiet' to compare files outside the
repository.
git-difftool.perl | 7 +++++--
1 file changed, 5 insertions(+), 2 deletions(-)
diff --git a/git-difftool.perl b/git-difftool.perl
index ae1e052..679a56d 100755
--- a/git-difftool.perl
+++ b/git-difftool.perl
@@ -336,8 +336,11 @@ if (defined($dirdiff)) {
# 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") &&
+ (system('git', 'diff', '--quiet', "$b/$file", "$workdir/$file") != 0)) {
Why waste cycles to spawn "git diff" when you only want to find if
they are byte-for-byte identical *and* when you are importing many
perl modules from File::* already into the script?
+ copy("$b/$file", "$workdir/$file") or die $!;
+ chmod(stat("$b/$file")->mode, "$workdir/$file") or die $!;
+ }
}
} else {
if (defined($prompt)) {
On Thu, Jun 28, 2012 at 12:51 PM, Junio C Hamano [off-list ref] wrote:
Tim Henigan [off-list ref] writes:
quoted
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 <redacted>
---
This patch must be applied after commit 304970d on next (diff-no-index:
exit(1) if 'diff --quiet <repo file> <external file>' finds changes).
because it relies on 'git diff --quiet' to compare files outside the
repository.
git-difftool.perl | 7 +++++--
1 file changed, 5 insertions(+), 2 deletions(-)
diff --git a/git-difftool.perl b/git-difftool.perl
index ae1e052..679a56d 100755
--- a/git-difftool.perl
+++ b/git-difftool.perl
@@ -336,8 +336,11 @@ if (defined($dirdiff)) {
# 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") &&
+ (system('git', 'diff', '--quiet', "$b/$file", "$workdir/$file") != 0)) {
Why waste cycles to spawn "git diff" when you only want to find if
they are byte-for-byte identical *and* when you are importing many
perl modules from File::* already into the script?
quoted
+ copy("$b/$file", "$workdir/$file") or die $!;
+ chmod(stat("$b/$file")->mode, "$workdir/$file") or die $!;
+ }
}
} else {
if (defined($prompt)) {
Hey Tim,
I think what Junio is alluding to here is that we should probably use
File::Compare[1] here instead of shelling out to git. I hope that
helps.
Let me know if you need any help getting this patch into shape.
Thanks,
--
David
[1] http://perldoc.perl.org/File/Compare.html
From: Tim Henigan <redacted>
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 <redacted>
Signed-off-by: David Aguilar <redacted>
---
Perhaps something like this...
git-difftool.perl | 7 +++++--
1 file changed, 5 insertions(+), 2 deletions(-)
diff --git a/git-difftool.perl b/git-difftool.perl
index ae1e052..c079854 100755
--- a/git-difftool.perl
+++ b/git-difftool.perl
@@ -15,6 +15,7 @@ use strict;
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 @@ if (defined($dirdiff)) {
# 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)) {--
1.7.11.2.250.g00b4b9a