Can Git merge โ€œuseโ€ information found with Git to blame -C

This question came to me after reading this: Can Git really track the movement of one function from one file to another? If so, how?

This is worfklow:

A "long time ago" we shared a large file folder/file.py in many files: folder1/file.py , folder2/file.py , etc.

git blame -C correctly shows the history of this code, when we look at folder2/file.py , we see that some of the commits were made before this splitting.

The problem is that we continue to support old versions of the code that still have folder/file.py , and when we combine the fixes in the "current" version, Git continues to recreate the folder folder and does not see that the correction made to folder/file.py , should be merged into folder1/file.py OR folder2/file.py depending on where this piece of code is now located.

I quickly look at git help merge , but found nothing about it.

+4
source share
1 answer

Merges cannot use git blame -C , but git merge has a rename. On the man page:

  rename-threshold=<n> Controls the similarity threshold used for rename detection. See also git-diff(1) -M. 

Git Rename Threshold is probably too high to detect your renames during merge. It is also possible that detection is being calculated too intensively. Try a test merge with a lower rename threshold, say 75:

 git merge -X rename-threshold=75 <branch> 

It may take you a while to find the number you need, and if git quits because it is too hard to calculate, try setting git config merge.renamelimit 0 , discussed in the thread mentioned above.

This answer may also help if the above fails. I have not tried -X ignore-space-change or a related script, but this may be worth the investigation.

0
source

All Articles