Re: What's cooking in git/spearce.git (topics)

Previous message: [thread] [date] [author]
Next message: [thread] [date] [author]
From: Jeff King
Date: Monday, October 22, 2007 - 12:16 am

On Mon, Oct 22, 2007 at 02:32:22AM -0400, Shawn O. Pearce wrote:


Hrm, the problem is that it's not favoring basenames anymore. But I
think it is because the loop in find_identical_files is inside out. For
every source file, it picks the best destination file. But I think we
want to do the opposite: for every destination file, pick the best
source file. Otherwise, if a non-basename source file is connected with
a particular destination file, we no longer try that destination file
again.

Patch is below (please just squash with the one from Linus).

diff --git a/diffcore-rename.c b/diffcore-rename.c
index 05d39db..8881818 100644
--- a/diffcore-rename.c
+++ b/diffcore-rename.c
@@ -252,17 +252,18 @@ static int find_identical_files(struct file_similarity *src,
 {
 	int renames = 0;
 	do {
-		struct diff_filespec *one = src->filespec;
+		struct diff_filespec *one = dst->filespec;
 		struct file_similarity *p, *best;
 		int i = 100;
 
 		best = NULL;
-		for (p = dst; p; p = p->next) {
+		for (p = src; p; p = p->next) {
 			struct diff_filespec *two = p->filespec;
 
-			/* Already picked as a destination? */
+			/* Already picked as a source? */
 			if (!p->src_dst)
 				continue;
+
 			/* False hash collission? */
 			if (hashcmp(one->sha1, two->sha1))
 				continue;
@@ -276,10 +277,10 @@ static int find_identical_files(struct file_similarity *src,
 		}
 		if (best) {
 			best->src_dst = 0;
-			record_rename_pair(best->index, src->index, MAX_SCORE);
+			record_rename_pair(dst->index, best->index, MAX_SCORE);
 			renames++;
 		}
-	} while ((src = src->next) != NULL);
+	} while ((dst = dst->next) != NULL);
 	return renames;
 }
 
-
To unsubscribe from this list: send the line "unsubscribe git" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Previous message: [thread] [date] [author]
Next message: [thread] [date] [author]

Messages in current thread:
What's cooking in git/spearce.git (topics), Shawn O. Pearce, (Sun Oct 21, 11:32 pm)
Re: What's cooking in git/spearce.git (topics), Jeff King, (Sun Oct 21, 11:59 pm)
Re: What's cooking in git/spearce.git (topics), Jeff King, (Mon Oct 22, 12:16 am)
Re: What's cooking in git/spearce.git (topics), Pierre Habouzit, (Mon Oct 22, 12:24 am)
Re: What's cooking in git/spearce.git (topics), Steffen Prohaska, (Mon Oct 22, 8:27 am)
Re: What's cooking in git/spearce.git (topics), Junio C Hamano, (Mon Oct 22, 6:26 pm)
Re: What's cooking in git/spearce.git (topics), Linus Torvalds, (Mon Oct 22, 7:32 pm)
Re: What's cooking in git/spearce.git (topics), Shawn O. Pearce, (Mon Oct 22, 8:34 pm)
Re: What's cooking in git/spearce.git (topics), Jeff King, (Mon Oct 22, 8:48 pm)
What's cooking in git.git (topics), Junio C Hamano, (Wed Oct 24, 5:51 am)
Re: What's cooking in git.git (topics), David Symonds, (Wed Oct 24, 6:09 am)
Re: What's cooking in git.git (topics), Scott Parish, (Wed Oct 24, 9:08 am)
Re: What's cooking in git.git (topics), Andreas Ericsson, (Wed Oct 24, 11:27 am)
Re: What's cooking in git.git (topics), Scott Parish, (Wed Oct 24, 5:35 pm)
What's cooking in git.git (topics), Junio C Hamano, (Wed Oct 31, 10:41 pm)
Re: What's cooking in git.git (topics), Linus Torvalds, (Thu Nov 1, 11:33 am)
Re: What's cooking in git.git (topics), Geert Bosch, (Thu Nov 1, 12:19 pm)
Re: What's cooking in git.git (topics), Junio C Hamano, (Thu Nov 1, 1:27 pm)
Re: What's cooking in git.git (topics), Mike Hommey, (Thu Nov 1, 1:47 pm)
Re: What's cooking in git.git (topics), Geert Bosch, (Thu Nov 1, 2:17 pm)
Re: What's cooking in git.git (topics), Theodore Tso, (Thu Nov 1, 2:18 pm)
Re: What's cooking in git.git (topics), Junio C Hamano, (Thu Nov 1, 2:20 pm)
Re: What's cooking in git.git (topics), Melchior FRANZ, (Thu Nov 1, 2:26 pm)
Re: What's cooking in git.git (topics), Johan Herland, (Thu Nov 1, 2:32 pm)
Re: What's cooking in git.git (topics), Brian Downing, (Thu Nov 1, 2:41 pm)
Re: What's cooking in git.git (topics), Pierre Habouzit, (Thu Nov 1, 2:42 pm)
Re: What's cooking in git.git (topics), Pierre Habouzit, (Thu Nov 1, 2:44 pm)
Re: What's cooking in git.git (topics), Pierre Habouzit, (Thu Nov 1, 2:46 pm)
Re: What's cooking in git.git (topics), Junio C Hamano, (Thu Nov 1, 2:51 pm)
Re: What's cooking in git.git (topics), Pierre Habouzit, (Thu Nov 1, 2:57 pm)
Re: What's cooking in git.git (topics), Linus Torvalds, (Thu Nov 1, 3:05 pm)
Re: What's cooking in git.git (topics), Bill Lear, (Thu Nov 1, 3:26 pm)
Re: What's cooking in git.git (topics), Junio C Hamano, (Thu Nov 1, 3:50 pm)
Re: What's cooking in git.git (topics), Jonas Fonseca, (Thu Nov 1, 5:00 pm)
Re: What's cooking in git.git (topics), Junio C Hamano, (Thu Nov 1, 5:32 pm)
Re: What's cooking in git.git (topics), Petr Baudis, (Thu Nov 1, 7:19 pm)
Re: What's cooking in git.git (topics), Miles Bader, (Thu Nov 1, 11:06 pm)
Re: What's cooking in git.git (topics), Andreas Ericsson, (Fri Nov 2, 2:38 am)
Re: What's cooking in git.git (topics), Andreas Ericsson, (Fri Nov 2, 2:39 am)
Re: What's cooking in git.git (topics), Wincent Colaiuta, (Fri Nov 2, 3:26 am)
Re: What's cooking in git.git (topics), Johannes Schindelin, (Fri Nov 2, 4:03 am)
Re: What's cooking in git.git (topics), Miles Bader, (Fri Nov 2, 8:13 am)
What's cooking in git.git (topics), Junio C Hamano, (Sat Nov 3, 9:14 pm)
Re: What's cooking in git.git (topics), Pierre Habouzit, (Sun Nov 4, 4:38 am)
What's cooking in git.git (topics), Junio C Hamano, (Thu Nov 8, 1:08 am)
Re: What's cooking in git.git (topics), Steffen Prohaska, (Thu Nov 8, 1:44 pm)
What's cooking in git.git (topics), Junio C Hamano, (Mon Nov 12, 12:09 am)
Re: What's cooking in git.git (topics), Johannes Schindelin, (Mon Nov 12, 5:21 am)
Re: What's cooking in git.git (topics), Pierre Habouzit, (Mon Nov 12, 5:26 am)
Re: What's cooking in git.git (topics), Johannes Schindelin, (Mon Nov 12, 5:33 am)
[PATCH] rebase: brown paper bag fix after the detached HEA ..., Johannes Schindelin, (Mon Nov 12, 6:11 am)
Re: What's cooking in git.git (topics), Steffen Prohaska, (Mon Nov 12, 7:27 am)
Re: What's cooking in git.git (topics), Pierre Habouzit, (Mon Nov 12, 7:53 am)
Re: What's cooking in git.git (topics), Johannes Schindelin, (Mon Nov 12, 8:02 am)
What's cooking in git.git (topics), Junio C Hamano, (Wed Nov 14, 5:18 pm)
Re: What's cooking in git.git (topics), Johannes Schindelin, (Wed Nov 14, 5:49 pm)
Re: What's cooking in git.git (topics), Jeff King, (Sat Nov 17, 5:40 am)
Re: [PATCH 2/2] push: Add '--current', which pushes only t ..., Steffen Prohaska, (Sun Nov 18, 11:41 pm)