You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
File rename operations in a git commit are identified by computing the similarity (percentage of lines unchanged) of added/removed pairs of files in the commit. If the similarity exceeds some threshold, the deletion and addition are considered a file rename.
Git’s similarity threshold for rename detection is configurable and defaults to 50%. This is clearly documented, and Google knows it well.
JGit’s similarity threshold for rename detection is not configurable and is 60%. That constant was introduced in 2010 (978535b).
The threshold discrepancy manifests often in Gerrit code reviews (see Gerrit bug 40015217 for examples), but it can also manifest in the output of simple commands like:
jgit status
jgit diff
jgit log
jgit show
Steps to reproduce
In any empty or existing git repository, run the following commands:
echo $'1\n2\n3\n4\n5\n6\n7\n8' > a.txt
git add a.txt
git commit -m a.txt
git rm a.txt
echo $'1\n2\n3\n4\n5.\n6.\n7.\n8' > b.txt
git add b.txt
git status
jgit status
git commit -m b.txt
git show
jgit show
Actual behavior
The jgit status output is:
Changes to be committed:
deleted: a.txt
new file: b.txt
void RenameDetector.setRenameScore(int score) provides the API to configure the score. RenameDetector DiffFormatter.getRenameDetector() can be used to access the rename detector it's using and configure it using setRenameScore(int score).
Version
7.0.0
Operating System
Linux/Unix, MacOS
Bug description
File rename operations in a git commit are identified by computing the similarity (percentage of lines unchanged) of added/removed pairs of files in the commit. If the similarity exceeds some threshold, the deletion and addition are considered a file rename.
Git’s similarity threshold for rename detection is configurable and defaults to 50%. This is clearly documented, and Google knows it well.
JGit’s similarity threshold for rename detection is not configurable and is 60%. That constant was introduced in 2010 (978535b).
The threshold discrepancy manifests often in Gerrit code reviews (see Gerrit bug 40015217 for examples), but it can also manifest in the output of simple commands like:
jgit status
jgit diff
jgit log
jgit show
Steps to reproduce
In any empty or existing git repository, run the following commands:
echo $'1\n2\n3\n4\n5\n6\n7\n8' > a.txt
git add a.txt
git commit -m a.txt
git rm a.txt
echo $'1\n2\n3\n4\n5.\n6.\n7.\n8' > b.txt
git add b.txt
git status
jgit status
git commit -m b.txt
git show
jgit show
Actual behavior
The
jgit status
output is:The
jgit show
output is:Expected behavior
I expected the
jgit status
output to roughly match thegit status
output, identifying the staged changes as a file rename:I also expected the
jgit show
output to roughly match thegit show
output, identifying the commit’s changes as a file rename:Relevant log output
No response
Other information
No response
The text was updated successfully, but these errors were encountered: