Handle MR diffs for moved-and-changed files correctly
Release notes
Introduce git show --find-renames
functionality to show MR diffs for moved-and-changed files nicely.
Problem to solve
I have MR consisting of two commits:
- first commit just moves the file mostly (and it looks good)
- second commit does actual changes to the files (it also looks OK)
The problem is - I and other reviewers can't see actual changes for the moved file in the whole MR: instead, it looks like if the old file was deleted and then new one is added
Intended users
User experience goal
The user should be able to use the UI with GitLab to set a threshold on the similarity index (i.e. amount of addition/deletions compared to the file’s size) to achieve proper MR representation.
Proposal
Implement UI for Git's show/diff --find-renames
option:
-M[<n>], --find-renames[=<n>]
If generating diffs, detect and report renames for each commit. For following files across renames while traversing history, see --follow. 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. Without a % sign, the number is to be read as a fraction, with a decimal point before it. I.e., -M5 becomes 0.5, and is thus the same as -M50%. Similarly, -M05 is the same as -M5%. To limit detection to exact renames, use -M100%. The default similarity index is 50%.
For example, the MR above shows good result with the following command: git show -M15%