Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Change threshold on the similarity index for git merge with renaming involved (like -M[n] --find-renames[=n] on diff)

Tags:

git

dvcs

We have some configuration options for the rename detection heuristics during diff (log, show) and merge:

diff.renameLimit The number of files to consider when performing the copy/rename detection; equivalent to the git diff option -l.

diff.renames Tells git to detect renames. If set to any boolean value, it will enable basic rename detection. If set to "copies" or "copy", it will detect copies, as well.

merge.renameLimit The number of files to consider when performing rename detection during a merge; if not specified, defaults to the value of diff.renameLimit.

Also we have an option to control when files with different contents are considered a rename for diff (log, show):

-M[<n>] (or --find-renames[=<n>])

Detect renames. If n is specified, it is a threshold on the similarity index (i.e. amount of addition/deletions compared to the file’s size). For example, -M90% means git should consider a delete/add pair to be a rename if more than 90% of the file hasn’t changed.

QUESTION: How to control a threshold on the similarity index for merge? It seems to be available only as a command-line option for diff and some others but not merge. And no configuration key even for diff. Is it not applicable for merge for some reason?

like image 452
IgorK Avatar asked Jan 11 '12 21:01

IgorK


1 Answers

If you're merging with the recursive merge strategy (default) you can use the rename-threshold option:

git merge -X rename-threshold=80 branch
like image 188
lhunath Avatar answered Nov 14 '22 15:11

lhunath