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

Re: Pure renames/copies

From
Junio C Hamano <junkio@cox.net>
Date
Nov 21, 2005, 19:50 UTC
Message-ID
<7vacfxrdao.fsf@assigned-by-dhcp.cox.net>
In-Reply-To
<Pine.LNX.4.64.0511211020130.13959@g5.osdl.org>
Linus Torvalds <torvalds@osdl.org> writes:
> Of course, arguably "-M100" should really do this optimization for you. 
> Junio?
Probably something like this would suffice.
-- >8 --
Subject: rename detection with -M100 means "exact renames only".

When the user is interested in pure renames, there is no point doing the similarity scores. This changes the score argument parsing to special case -M100 (otherwise, it is a precision scaled value 0 <= v < 1 and would mean 0.1, not 1.0 --- if you do mean 0.1, you can say -M1), and optimizes the diffcore_rename transformation to only look at pure renames in that case.

Signed-off-by: Junio C Hamano <junkio@cox.net>
---
diff --git a/diff.c b/diff.c
index 0391e8c..0f839c1 100644
--- a/diff.c
+++ b/diff.c
@@ -853,6 +853,10 @@ static int parse_num(const char **cp_p)
 	}
 	*cp_p = cp;
 
+	/* special case: -M100 would mean 1.0 not 0.1 */
+	if (num == 100 && scale == 1000)
+		return MAX_SCORE;
+
 	/* user says num divided by scale and we say internally that
 	 * is MAX_SCORE * num / scale.
 	 */
diff --git a/diffcore-rename.c b/diffcore-rename.c
index 6a9d95d..dba965c 100644
--- a/diffcore-rename.c
+++ b/diffcore-rename.c
@@ -307,6 +307,9 @@ void diffcore_rename(struct diff_options
 	if (rename_count == rename_dst_nr)
 		goto cleanup;
 
+	if (minimum_score == MAX_SCORE)
+		goto cleanup;
+
 	num_create = (rename_dst_nr - rename_count);
 	num_src = rename_src_nr;
 	mx = xmalloc(sizeof(*mx) * num_create * num_src);
Previous: Junio C HamanoNext: H. Peter Anvin
Message 4 of 11 in “Pure renames/copies”
  1. Santi BéjarNov 21, 2005
  2. Linus TorvaldsNov 21, 2005
  3. Junio C HamanoNov 21, 2005
  4. Junio C HamanoNov 21, 2005
  5. H. Peter AnvinNov 21, 2005
  6. Junio C HamanoNov 21, 2005
  7. H. Peter AnvinNov 21, 2005
  8. Junio C HamanoNov 21, 2005
  9. H. Peter AnvinNov 21, 2005
  10. H. Peter AnvinNov 21, 2005
  11. Santi BejarNov 22, 2005

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.