git.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH 1/2] difftool: only copy back files modified during directory diff
@ 2012-06-28 19:39 Tim Henigan
  2012-06-28 19:39 ` [PATCH 2/2] difftool: handle uninitialized variable on empty diff Tim Henigan
  2012-06-28 19:51 ` [PATCH 1/2] difftool: only copy back files modified during directory diff Junio C Hamano
  0 siblings, 2 replies; 8+ messages in thread
From: Tim Henigan @ 2012-06-28 19:39 UTC (permalink / raw)
  To: gitster, git, davvid; +Cc: Tim Henigan

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>
---

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)) {
+			copy("$b/$file", "$workdir/$file") or die $!;
+			chmod(stat("$b/$file")->mode, "$workdir/$file") or die $!;
+		}
 	}
 } else {
 	if (defined($prompt)) {
-- 
1.7.11.1.134.gda62046

^ permalink raw reply related	[flat|nested] 8+ messages in thread

end of thread, other threads:[~2012-07-21  5:11 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2012-06-28 19:39 [PATCH 1/2] difftool: only copy back files modified during directory diff Tim Henigan
2012-06-28 19:39 ` [PATCH 2/2] difftool: handle uninitialized variable on empty diff Tim Henigan
2012-06-28 20:00   ` Junio C Hamano
2012-06-28 19:51 ` [PATCH 1/2] difftool: only copy back files modified during directory diff Junio C Hamano
2012-07-19  8:11   ` David Aguilar
2012-07-19  8:27     ` [PATCH v2] " David Aguilar
2012-07-19 17:34       ` Junio C Hamano
2012-07-21  5:10         ` David Aguilar

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).