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

[PATCH 3/3] diffcore-rename: improve estimate_similarity() heuristics

From
Linus Torvalds <torvalds@linux-foundation.org>
Date
Feb 19, 2011, 04:30 UTC
Message-ID
<alpine.LFD.2.02.1102182028410.4165@i5.linux-foundation.org>
In-Reply-To
<alpine.LFD.2.02.1102182025270.4165@i5.linux-foundation.org>
From: Linus Torvalds <torvalds@linux-foundation.org>
Date: Fri, 18 Feb 2011 20:12:06 -0800

The logic to quickly dismiss potential rename pairs was broken. It would too eagerly dismiss possible renames when all of the difference was due to pure new data (or deleted data).

Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
---

This is the trivial one-liner, now with a changelog and sign-off. It changes the percentage of the size difference (delta_size) to be compared against the larger file size rather than the smaller file size.

 diffcore-rename.c |    2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)
diff --git a/diffcore-rename.c b/diffcore-rename.c
index b9b039d..0cd4c13 100644
--- a/diffcore-rename.c
+++ b/diffcore-rename.c
@@ -170,7 +170,7 @@ static int estimate_similarity(struct diff_filespec *src,
 	 * and the final score computation below would not have a
 	 * divide-by-zero issue.
 	 */
-	if (base_size * (MAX_SCORE-minimum_score) < delta_size * MAX_SCORE)
+	if (max_size * (MAX_SCORE-minimum_score) < delta_size * MAX_SCORE)
 		return 0;
 
 	if (!src->cnt_data && diff_populate_filespec(src, 0))
-- 
1.7.4.1.51.g2bf8a
Previous: Linus Torvalds
Message 3 of 3 in “for_each_hash: allow passing a 'void *data' pointer to callback”
  1. 1/3 for_each_hash: allow passing a 'void *data' pointer to callbackLinus Torvalds, Feb 19, 2011
  2. 2/3 diffcore-rename: propler honor the difference between -M and -CLinus Torvalds, Feb 19, 2011
  3. 3/3 diffcore-rename: improve estimate_similarity() heuristicsLinus Torvalds, Feb 19, 2011

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.