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

Custom merge driver with no rename detection

From
FAFelipe Gonçalves Assis <felipeg.assis@gmail.com>
Date
Feb 14, 2016, 19:51 UTC
Message-ID
<CALMa68ovz=VZYkCcUDvEn1d7=xJDx__71caqsPXUFASZ1phfdw@mail.gmail.com>
Hi,

I would like to set up a Git repository with a custom merge driver, and then disable rename detection when merging.

Unfortunately, the recursive strategy has no "no-renames" option. Note that I would like to avoid rename detection even when the file contents perfectly match.

The usual workaround is using the resolve strategy, but apparently it ignores the custom merge driver. Besides, I would really like to use the recursive strategy logic.

Is there any solution to this in the current version?

If not, what do you think about adding a "no-renames" option to the recursive strategy? I could work on a patch.

Attached is a quick and dirty patch that emulates the effect by allowing greater than 100% rename thresholds to mean "no-renames".

And here is a related question on StackOverflow: http://stackoverflow.com/questions/35135517/custom-git-merge-driver-with-no-rename-detection

Thanks in advance for any attention provided.

Regards, Felipe Gonçalves Assis

From bcef6c44fac3a29afe03408ef27024776da861ee Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Felipe=20Gon=C3=A7alves=20Assis?= <felipegassis@gmail.com>
Date: Sun, 14 Feb 2016 17:02:00 -0200
Subject: [PATCH] diff: rename threshold above 100% means no renames
---
 diff.c            | 2 +-
 diffcore-rename.c | 2 +-
 2 files changed, 2 insertions(+), 2 deletions(-)
diff --git a/diff.c b/diff.c
index 2136b69..43b9e0a 100644
--- a/diff.c
+++ b/diff.c
@@ -4003,7 +4003,7 @@ int parse_rename_score(const char **cp_p)
 	/* user says num divided by scale and we say internally that
 	 * is MAX_SCORE * num / scale.
 	 */
-	return (int)((num >= scale) ? MAX_SCORE : (MAX_SCORE * num / scale));
+	return (int)(MAX_SCORE * num / scale);
 }
 
 static int diff_scoreopt_parse(const char *opt)
diff --git a/diffcore-rename.c b/diffcore-rename.c
index af1fe08..7cb5a3b 100644
--- a/diffcore-rename.c
+++ b/diffcore-rename.c
@@ -497,7 +497,7 @@ void diffcore_rename(struct diff_options *options)
 			register_rename_src(p);
 		}
 	}
-	if (rename_dst_nr == 0 || rename_src_nr == 0)
+	if (rename_dst_nr == 0 || rename_src_nr == 0 || minimum_score > MAX_SCORE)
 		goto cleanup; /* nothing to do */
 
 	/*
-- 
2.7.1.287.g4943984
Next: Junio C Hamano
Message 1 of 8 in “Custom merge driver with no rename detection”
  1. Felipe Gonçalves AssisFeb 14, 2016
  2. Junio C HamanoFeb 15, 2016
  3. Johannes SchindelinFeb 15, 2016
  4. Junio C HamanoFeb 15, 2016
  5. Johannes SchindelinFeb 15, 2016
  6. Felipe Gonçalves AssisFeb 15, 2016
  7. Junio C HamanoFeb 15, 2016
  8. Felipe Gonçalves AssisFeb 16, 2016

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.