From: "Felipe Gonçalves Assis" <felipeg.assis@gmail.com>
To: git@vger.kernel.org
Subject: Custom merge driver with no rename detection
Date: Sun, 14 Feb 2016 17:51:10 -0200 [thread overview]
Message-ID: <CALMa68ovz=VZYkCcUDvEn1d7=xJDx__71caqsPXUFASZ1phfdw@mail.gmail.com> (raw)
[-- Attachment #1: Type: text/plain, Size: 1005 bytes --]
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
[-- Attachment #2: 0001-diff-rename-threshold-above-100-means-no-renames.patch --]
[-- Type: text/x-patch, Size: 1208 bytes --]
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 reply other threads:[~2016-02-14 19:51 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2016-02-14 19:51 Felipe Gonçalves Assis [this message]
2016-02-15 5:10 ` Custom merge driver with no rename detection Junio C Hamano
2016-02-15 8:06 ` Johannes Schindelin
2016-02-15 9:57 ` Junio C Hamano
2016-02-15 8:06 ` Johannes Schindelin
2016-02-15 10:42 ` Felipe Gonçalves Assis
2016-02-15 11:03 ` Junio C Hamano
2016-02-16 1:04 ` Felipe Gonçalves Assis
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to='CALMa68ovz=VZYkCcUDvEn1d7=xJDx__71caqsPXUFASZ1phfdw@mail.gmail.com' \
--to=felipeg.assis@gmail.com \
--cc=git@vger.kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).