Skip to content

Commit

Permalink
Merge branch 'rename-bug'
Browse files Browse the repository at this point in the history
* rename-bug:
  Fix ArrayIndexOutOfBounds on non-square exact rename matrix

Conflicts:
	org.eclipse.jgit/src/org/eclipse/jgit/diff/RenameDetector.java

Change-Id: Ie0b8dd3e1ec174f79ba39dc4706bb0694cc8be29
  • Loading branch information
spearce committed Aug 6, 2010
2 parents 8e9cc82 + e2f5716 commit 09130b8
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 6 deletions.
Expand Up @@ -173,17 +173,20 @@ public void testExactRename_PathBreaksTie() throws Exception {

DiffEntry c = DiffEntry.add("c.txt", foo);
DiffEntry d = DiffEntry.delete("d.txt", foo);
DiffEntry e = DiffEntry.add("the_e_file.txt", foo);

// Add out of order to avoid first-match succeeding
rd.add(a);
rd.add(d);
rd.add(e);
rd.add(b);
rd.add(c);

List<DiffEntry> entries = rd.compute();
assertEquals(2, entries.size());
assertEquals(3, entries.size());
assertRename(d, c, 100, entries.get(0));
assertRename(b, a, 100, entries.get(1));
assertCopy(d, e, 100, entries.get(2));
}

public void testExactRename_OneDeleteManyAdds() throws Exception {
Expand Down
10 changes: 5 additions & 5 deletions org.eclipse.jgit/src/org/eclipse/jgit/diff/RenameDetector.java
Expand Up @@ -508,14 +508,14 @@ private void findExactRenames(ProgressMonitor pm) {
List<DiffEntry> dels = (List<DiffEntry>) o;
long[] matrix = new long[dels.size() * adds.size()];
int mNext = 0;
for (int addIdx = 0; addIdx < adds.size(); addIdx++) {
String addedName = adds.get(addIdx).newPath;
for (int delIdx = 0; delIdx < dels.size(); delIdx++) {
String deletedName = dels.get(delIdx).oldPath;

for (int delIdx = 0; delIdx < dels.size(); delIdx++) {
String deletedName = dels.get(delIdx).oldPath;
for (int addIdx = 0; addIdx < adds.size(); addIdx++) {
String addedName = adds.get(addIdx).newPath;

int score = SimilarityRenameDetector.nameScore(addedName, deletedName);
matrix[mNext] = SimilarityRenameDetector.encode(score, addIdx, delIdx);
matrix[mNext] = SimilarityRenameDetector.encode(score, delIdx, addIdx);
mNext++;
}
}
Expand Down

0 comments on commit 09130b8

Please sign in to comment.