git/list[1] front-page[2] threads[3] people[4] search[5] about
 

[PATCH] Fix several places where diff.renames in config can be problematic

From
EWEric Wong <normalperson@yhbt.net>
Date
Jul 8, 2006, 01:58 UTC
Message-ID
<20060708015844.GA13769@soma>
In-Reply-To
<7v64i9zk0j.fsf@assigned-by-dhcp.cox.net>
git-cvsexportcommit.perl:
git-cvsserver.perl:
	CVS can't handle renames, so we best not show them to
	users.
templates/hooks--update:
	replace diffstat calls with git diff --stat

There may be other places where users having diff.renames can be problematic, too. diff.renames is opt-in, but maybe some users have enabled it in their configs previously because it's been in examples for a long time...

Signed-off-by: Eric Wong <normalperson@yhbt.net>
---
 Junio C Hamano <junkio@cox.net> wrote:
 > Junio C Hamano <junkio@cox.net> writes:
 > 
 > > I am more worried about somebody who opts-in finds breakage of
 > > commands that happen to internally use low-level diff machinery
 > > and expect the diff machinery does not automagically do funny
 > > rename detection without being told.
 > > ...
 > > That is why I said I do not want this at _that_ low level.  I do
 > > not have objections to have the configuration at a layer closer
 > > to the UI, e.g. things in builtin-log.c and builtin-diff.c.
 > 
 > Upon closer look I think the revision pruning code is OK.  So
 > let's cook this as is in "next" and see what happens.
 Cool.  I've found these that could be potential issues.  There could be
 more, and possibly many in 3rd-party scripts outside our control, too.
 git-cvsexportcommit.perl |    8 +++++---
 git-cvsserver.perl       |    2 +-
 templates/hooks--update  |    4 ++--
 3 files changed, 8 insertions(+), 6 deletions(-)
diff --git a/git-cvsexportcommit.perl b/git-cvsexportcommit.perl
index d1051d0..09ff2cc 100755
--- a/git-cvsexportcommit.perl
+++ b/git-cvsexportcommit.perl
@@ -91,7 +91,8 @@ close MSG;
 $? && die "Error extracting the commit message";
 
 my (@afiles, @dfiles, @mfiles, @dirs);
-my @files = safe_pipe_capture('git-diff-tree', '-r', $parent, $commit);
+my @files = safe_pipe_capture('git-diff-tree','--no-renames','-r',
+				$parent, $commit);
 #print @files;
 $? && die "Error in git-diff-tree";
 foreach my $f (@files) {
@@ -175,7 +176,8 @@ foreach my $d (@dirs) {
 
 print "'Patching' binary files\n";
 
-my @bfiles = grep(m/^Binary/, safe_pipe_capture('git-diff-tree', '-p', $parent, $commit));
+my @bfiles = grep(m/^Binary/, safe_pipe_capture('git-diff-tree','--no-renames',
+						'-p', $parent, $commit));
 @bfiles = map { chomp } @bfiles;
 foreach my $f (@bfiles) {
     # check that the file in cvs matches the "old" file
@@ -206,7 +208,7 @@ ## apply non-binary changes
 my $fuzz = $opt_p ? 0 : 2;
 
 print "Patching non-binary files\n";
-print `(git-diff-tree -p $parent -p $commit | patch -p1 -F $fuzz ) 2>&1`;
+print `(git-diff-tree --no-renames -p $parent -p $commit | patch -p1 -F $fuzz ) 2>&1`;
 
 my $dirtypatch = 0;
 if (($? >> 8) == 2) {
diff --git a/git-cvsserver.perl b/git-cvsserver.perl
index 5ccca4f..ae878ea 100755
--- a/git-cvsserver.perl
+++ b/git-cvsserver.perl
@@ -2295,7 +2295,7 @@ sub update
 
         if ( defined ( $lastpicked ) )
         {
-            my $filepipe = open(FILELIST, '-|', 'git-diff-tree', '-r', $lastpicked, $commit->{hash}) or die("Cannot call git-diff-tree : $!");
+            my $filepipe = open(FILELIST, '-|', 'git-diff-tree', '--no-merges', '-r', $lastpicked, $commit->{hash}) or die("Cannot call git-diff-tree : $!");
             while ( <FILELIST> )
             {
                 unless ( /^:\d{6}\s+\d{3}(\d)\d{2}\s+[a-zA-Z0-9]{40}\s+([a-zA-Z0-9]{40})\s+(\w)\s+(.*)$/o )
diff --git a/templates/hooks--update b/templates/hooks--update
index d7a8f0a..76d5ac2 100644
--- a/templates/hooks--update
+++ b/templates/hooks--update
@@ -60,7 +60,7 @@ then
 			echo "Changes since $prev:"
 			git rev-list --pretty $prev..$3 | $short
 			echo ---
-			git diff $prev..$3 | diffstat -p1
+			git diff --stat $prev..$3
 			echo ---
 		fi
 		;;
@@ -75,7 +75,7 @@ else
 	base=$(git-merge-base "$2" "$3")
 	case "$base" in
 	"$2")
-		git diff "$3" "^$base" | diffstat -p1
+		git diff --stat "$3" "^$base"
 		echo
 		echo "New commits:"
 		;;
-- 
1.4.1.gc57e
Previous: Junio C HamanoNext: Junio C Hamano
Message 8 of 13 in “I forgot to run format-patch with the -M flag”
  1. 0/1 I forgot to run format-patch with the -M flagEric Wong, Jul 7, 2006
  2. diff.c: respect diff.renames config optionEric Wong, Jul 7, 2006
  3. builtin-log: respect diff configuration optionsEric Wong, Jul 7, 2006
  4. Junio C HamanoJul 7, 2006
  5. Junio C HamanoJul 7, 2006
  6. Junio C HamanoJul 7, 2006
  7. Junio C HamanoJul 7, 2006
  8. Fix several places where diff.renames in config can be problematicEric Wong, Jul 8, 2006
  9. Junio C HamanoJul 8, 2006
  10. Eric WongJul 8, 2006
  11. templates/hooks--update: replace diffstat calls with git diff --statEric Wong, Jul 8, 2006
  12. Junio C HamanoJul 7, 2006
  13. update Documentation/diff-options.txtJunio C Hamano, Jul 7, 2006

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.