Browse Source

Merge branch 'js/diff'

* js/diff:
  Fixed bug in scoring mechanism for rename detection
stable-0.9
Shawn O. Pearce 15 years ago
parent
commit
7514a6dbdc
  1. 15
      org.eclipse.jgit.test/tst/org/eclipse/jgit/diff/RenameDetectorTest.java
  2. 3
      org.eclipse.jgit/src/org/eclipse/jgit/diff/SimilarityIndex.java

15
org.eclipse.jgit.test/tst/org/eclipse/jgit/diff/RenameDetectorTest.java

@ -275,6 +275,21 @@ public class RenameDetectorTest extends RepositoryTestCase {
assertRename(b, a, 74, entries.get(0));
}
public void testInexactRename_SameContentMultipleTimes() throws Exception {
ObjectId aId = blob("a\na\na\na\n");
ObjectId bId = blob("a\na\na\n");
DiffEntry a = DiffEntry.add(PATH_A, aId);
DiffEntry b = DiffEntry.delete(PATH_Q, bId);
rd.add(a);
rd.add(b);
List<DiffEntry> entries = rd.compute();
assertEquals(1, entries.size());
assertRename(b, a, 74, entries.get(0));
}
public void testInexactRenames_OnePair2() throws Exception {
ObjectId aId = blob("ab\nab\nab\nac\nad\nae\n");
ObjectId bId = blob("ac\nab\nab\nab\naa\na0\na1\n");

3
org.eclipse.jgit/src/org/eclipse/jgit/diff/SimilarityIndex.java

@ -216,7 +216,8 @@ class SimilarityIndex {
for (;;) {
if (srcKey == dstKey) {
common += countOf(dstHash[dstIdx]);
common += Math.min(countOf(srcHash[srcIdx]),
countOf(dstHash[dstIdx]));
if (++srcIdx == srcHash.length)
break;

Loading…
Cancel
Save