Re: [PATCH v2] difftool: only copy back files modified during directory diff

2012-07-20 Thread David Aguilar
On Thu, Jul 19, 2012 at 10:34 AM, Junio C Hamano gits...@pobox.com wrote:
 David Aguilar dav...@gmail.com writes:

 Perhaps something like this...

 Yeah, like that ;-).

Hmm.. this one was potentially data-losing.  Sorry for not catching
that in 7e0abcec103b3649943b236881cf88e8fd6cf3a4.

$ git tag --contains 7e0abcec103b3649943b236881cf88e8fd6cf3a4
v1.7.11
v1.7.11.1
v1.7.11.2

maint, please?

I don't like complexity either, but adding a --symlinks option (and
making it the default) to create symlinks instead of copies really
does seem like the way to go long-term.  Then we can avoid the whole
copy-back business when in this mode.

I'll start exploring this unless you beat me to it, Tim ;-)
-- 
David
--
To unsubscribe from this list: send the line unsubscribe git in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH v2] difftool: only copy back files modified during directory diff

2012-07-19 Thread David Aguilar
From: Tim Henigan tim.heni...@gmail.com

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.heni...@gmail.com
Signed-off-by: David Aguilar dav...@gmail.com
---

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

--
To unsubscribe from this list: send the line unsubscribe git in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [PATCH v2] difftool: only copy back files modified during directory diff

2012-07-19 Thread Junio C Hamano
David Aguilar dav...@gmail.com writes:

 Perhaps something like this...

Yeah, like that ;-).
--
To unsubscribe from this list: send the line unsubscribe git in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html