Browse Source

Rename getOldName,getNewName to getOldPath,getNewPath

TreeWalk calls this value "path", while "name" is the stuff after the
last slash.  FileHeader should do the same thing to be consistent.
Rename getOldName to getOldPath and getNewName to getNewPath.

Bug: 318526
Change-Id: Ib2e372ad4426402d37939b48d8f233154cc637da
Signed-off-by: Shawn O. Pearce <spearce@spearce.org>
stable-0.9
Shawn O. Pearce 14 years ago
parent
commit
60c5939b23
  1. 10
      org.eclipse.jgit.pgm/src/org/eclipse/jgit/pgm/Diff.java
  2. 6
      org.eclipse.jgit.pgm/src/org/eclipse/jgit/pgm/Log.java
  3. 4
      org.eclipse.jgit.test/exttst/org/eclipse/jgit/patch/EGitPatchHistoryTest.java
  4. 16
      org.eclipse.jgit.test/tst/org/eclipse/jgit/diff/RenameDetectorTest.java
  5. 84
      org.eclipse.jgit.test/tst/org/eclipse/jgit/patch/FileHeaderTest.java
  6. 12
      org.eclipse.jgit.test/tst/org/eclipse/jgit/patch/PatchCcTest.java
  7. 10
      org.eclipse.jgit.test/tst/org/eclipse/jgit/patch/PatchErrorTest.java
  8. 18
      org.eclipse.jgit.test/tst/org/eclipse/jgit/patch/PatchTest.java
  9. 62
      org.eclipse.jgit/src/org/eclipse/jgit/diff/DiffEntry.java
  10. 12
      org.eclipse.jgit/src/org/eclipse/jgit/diff/DiffFormatter.java
  11. 16
      org.eclipse.jgit/src/org/eclipse/jgit/diff/RenameDetector.java
  12. 2
      org.eclipse.jgit/src/org/eclipse/jgit/diff/SimilarityRenameDetector.java
  13. 28
      org.eclipse.jgit/src/org/eclipse/jgit/patch/FileHeader.java
  14. 4
      org.eclipse.jgit/src/org/eclipse/jgit/revwalk/RewriteTreeFilter.java

10
org.eclipse.jgit.pgm/src/org/eclipse/jgit/pgm/Diff.java

@ -153,22 +153,22 @@ class Diff extends TextBuiltin {
for (DiffEntry ent : files) { for (DiffEntry ent : files) {
switch (ent.getChangeType()) { switch (ent.getChangeType()) {
case ADD: case ADD:
out.println("A\t" + ent.getNewName()); out.println("A\t" + ent.getNewPath());
break; break;
case DELETE: case DELETE:
out.println("D\t" + ent.getOldName()); out.println("D\t" + ent.getOldPath());
break; break;
case MODIFY: case MODIFY:
out.println("M\t" + ent.getNewName()); out.println("M\t" + ent.getNewPath());
break; break;
case COPY: case COPY:
out.format("C%1$03d\t%2$s\t%3$s", ent.getScore(), // out.format("C%1$03d\t%2$s\t%3$s", ent.getScore(), //
ent.getOldName(), ent.getNewName()); ent.getOldPath(), ent.getNewPath());
out.println(); out.println();
break; break;
case RENAME: case RENAME:
out.format("R%1$03d\t%2$s\t%3$s", ent.getScore(), // out.format("R%1$03d\t%2$s\t%3$s", ent.getScore(), //
ent.getOldName(), ent.getNewName()); ent.getOldPath(), ent.getNewPath());
out.println(); out.println();
break; break;
} }

6
org.eclipse.jgit.pgm/src/org/eclipse/jgit/pgm/Log.java

@ -242,7 +242,7 @@ class Log extends RevWalkTextBuiltin {
String oldPath = ((FollowFilter) pathFilter).getPath(); String oldPath = ((FollowFilter) pathFilter).getPath();
for (DiffEntry ent : files) { for (DiffEntry ent : files) {
if (ent.getChangeType() == ChangeType.ADD if (ent.getChangeType() == ChangeType.ADD
&& ent.getNewName().equals(oldPath)) && ent.getNewPath().equals(oldPath))
return true; return true;
} }
return false; return false;
@ -251,8 +251,8 @@ class Log extends RevWalkTextBuiltin {
private List<DiffEntry> updateFollowFilter(List<DiffEntry> files) { private List<DiffEntry> updateFollowFilter(List<DiffEntry> files) {
String oldPath = ((FollowFilter) pathFilter).getPath(); String oldPath = ((FollowFilter) pathFilter).getPath();
for (DiffEntry ent : files) { for (DiffEntry ent : files) {
if (isRename(ent) && ent.getNewName().equals(oldPath)) { if (isRename(ent) && ent.getNewPath().equals(oldPath)) {
pathFilter = FollowFilter.create(ent.getOldName()); pathFilter = FollowFilter.create(ent.getOldPath());
return Collections.singletonList(ent); return Collections.singletonList(ent);
} }
} }

4
org.eclipse.jgit.test/exttst/org/eclipse/jgit/patch/EGitPatchHistoryTest.java

@ -108,9 +108,9 @@ public class EGitPatchHistoryTest extends TestCase {
for (final FileHeader fh : p.getFiles()) { for (final FileHeader fh : p.getFiles()) {
final String fileName; final String fileName;
if (fh.getChangeType() != FileHeader.ChangeType.DELETE) if (fh.getChangeType() != FileHeader.ChangeType.DELETE)
fileName = fh.getNewName(); fileName = fh.getNewPath();
else else
fileName = fh.getOldName(); fileName = fh.getOldPath();
final StatInfo s = files.remove(fileName); final StatInfo s = files.remove(fileName);
final String nid = fileName + " in " + cid; final String nid = fileName + " in " + cid;
assertNotNull("No " + nid, s); assertNotNull("No " + nid, s);

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

@ -498,10 +498,10 @@ public class RenameDetectorTest extends RepositoryTestCase {
assertEquals(1, entries.size()); assertEquals(1, entries.size());
DiffEntry modify = entries.get(0); DiffEntry modify = entries.get(0);
assertEquals(m.oldName, modify.oldName); assertEquals(m.oldPath, modify.oldPath);
assertEquals(m.oldId, modify.oldId); assertEquals(m.oldId, modify.oldId);
assertEquals(m.oldMode, modify.oldMode); assertEquals(m.oldMode, modify.oldMode);
assertEquals(m.newName, modify.newName); assertEquals(m.newPath, modify.newPath);
assertEquals(m.newId, modify.newId); assertEquals(m.newId, modify.newId);
assertEquals(m.newMode, modify.newMode); assertEquals(m.newMode, modify.newMode);
assertEquals(m.changeType, modify.changeType); assertEquals(m.changeType, modify.changeType);
@ -560,8 +560,8 @@ public class RenameDetectorTest extends RepositoryTestCase {
DiffEntry rename) { DiffEntry rename) {
assertEquals(ChangeType.RENAME, rename.getChangeType()); assertEquals(ChangeType.RENAME, rename.getChangeType());
assertEquals(o.getOldName(), rename.getOldName()); assertEquals(o.getOldPath(), rename.getOldPath());
assertEquals(n.getNewName(), rename.getNewName()); assertEquals(n.getNewPath(), rename.getNewPath());
assertEquals(o.getOldMode(), rename.getOldMode()); assertEquals(o.getOldMode(), rename.getOldMode());
assertEquals(n.getNewMode(), rename.getNewMode()); assertEquals(n.getNewMode(), rename.getNewMode());
@ -576,8 +576,8 @@ public class RenameDetectorTest extends RepositoryTestCase {
DiffEntry copy) { DiffEntry copy) {
assertEquals(ChangeType.COPY, copy.getChangeType()); assertEquals(ChangeType.COPY, copy.getChangeType());
assertEquals(o.getOldName(), copy.getOldName()); assertEquals(o.getOldPath(), copy.getOldPath());
assertEquals(n.getNewName(), copy.getNewName()); assertEquals(n.getNewPath(), copy.getNewPath());
assertEquals(o.getOldMode(), copy.getOldMode()); assertEquals(o.getOldMode(), copy.getOldMode());
assertEquals(n.getNewMode(), copy.getNewMode()); assertEquals(n.getNewMode(), copy.getNewMode());
@ -590,11 +590,11 @@ public class RenameDetectorTest extends RepositoryTestCase {
private static void assertAdd(String newName, ObjectId newId, private static void assertAdd(String newName, ObjectId newId,
FileMode newMode, DiffEntry add) { FileMode newMode, DiffEntry add) {
assertEquals(DiffEntry.DEV_NULL, add.oldName); assertEquals(DiffEntry.DEV_NULL, add.oldPath);
assertEquals(DiffEntry.A_ZERO, add.oldId); assertEquals(DiffEntry.A_ZERO, add.oldId);
assertEquals(FileMode.MISSING, add.oldMode); assertEquals(FileMode.MISSING, add.oldMode);
assertEquals(ChangeType.ADD, add.changeType); assertEquals(ChangeType.ADD, add.changeType);
assertEquals(newName, add.newName); assertEquals(newName, add.newPath);
assertEquals(AbbreviatedObjectId.fromObjectId(newId), add.newId); assertEquals(AbbreviatedObjectId.fromObjectId(newId), add.newId);
assertEquals(newMode, add.newMode); assertEquals(newMode, add.newMode);
} }

84
org.eclipse.jgit.test/tst/org/eclipse/jgit/patch/FileHeaderTest.java

@ -79,16 +79,16 @@ public class FileHeaderTest extends TestCase {
final FileHeader fh = header(name); final FileHeader fh = header(name);
assertEquals(gitLine(name).length(), fh.parseGitFileName(0, assertEquals(gitLine(name).length(), fh.parseGitFileName(0,
fh.buf.length)); fh.buf.length));
assertEquals(name, fh.getOldName()); assertEquals(name, fh.getOldPath());
assertSame(fh.getOldName(), fh.getNewName()); assertSame(fh.getOldPath(), fh.getNewPath());
assertFalse(fh.hasMetaDataChanges()); assertFalse(fh.hasMetaDataChanges());
} }
public void testParseGitFileName_FailFooBar() { public void testParseGitFileName_FailFooBar() {
final FileHeader fh = data("a/foo b/bar\n-"); final FileHeader fh = data("a/foo b/bar\n-");
assertTrue(fh.parseGitFileName(0, fh.buf.length) > 0); assertTrue(fh.parseGitFileName(0, fh.buf.length) > 0);
assertNull(fh.getOldName()); assertNull(fh.getOldPath());
assertNull(fh.getNewName()); assertNull(fh.getNewPath());
assertFalse(fh.hasMetaDataChanges()); assertFalse(fh.hasMetaDataChanges());
} }
@ -97,8 +97,8 @@ public class FileHeaderTest extends TestCase {
final FileHeader fh = header(name); final FileHeader fh = header(name);
assertEquals(gitLine(name).length(), fh.parseGitFileName(0, assertEquals(gitLine(name).length(), fh.parseGitFileName(0,
fh.buf.length)); fh.buf.length));
assertEquals(name, fh.getOldName()); assertEquals(name, fh.getOldPath());
assertSame(fh.getOldName(), fh.getNewName()); assertSame(fh.getOldPath(), fh.getNewPath());
assertFalse(fh.hasMetaDataChanges()); assertFalse(fh.hasMetaDataChanges());
} }
@ -108,8 +108,8 @@ public class FileHeaderTest extends TestCase {
final FileHeader fh = dqHeader(dqName); final FileHeader fh = dqHeader(dqName);
assertEquals(dqGitLine(dqName).length(), fh.parseGitFileName(0, assertEquals(dqGitLine(dqName).length(), fh.parseGitFileName(0,
fh.buf.length)); fh.buf.length));
assertEquals(name, fh.getOldName()); assertEquals(name, fh.getOldPath());
assertSame(fh.getOldName(), fh.getNewName()); assertSame(fh.getOldPath(), fh.getNewPath());
assertFalse(fh.hasMetaDataChanges()); assertFalse(fh.hasMetaDataChanges());
} }
@ -119,8 +119,8 @@ public class FileHeaderTest extends TestCase {
final FileHeader fh = dqHeader(dqName); final FileHeader fh = dqHeader(dqName);
assertEquals(dqGitLine(dqName).length(), fh.parseGitFileName(0, assertEquals(dqGitLine(dqName).length(), fh.parseGitFileName(0,
fh.buf.length)); fh.buf.length));
assertEquals(name, fh.getOldName()); assertEquals(name, fh.getOldPath());
assertSame(fh.getOldName(), fh.getNewName()); assertSame(fh.getOldPath(), fh.getNewPath());
assertFalse(fh.hasMetaDataChanges()); assertFalse(fh.hasMetaDataChanges());
} }
@ -129,8 +129,8 @@ public class FileHeaderTest extends TestCase {
final FileHeader fh = header(name); final FileHeader fh = header(name);
assertEquals(gitLine(name).length(), fh.parseGitFileName(0, assertEquals(gitLine(name).length(), fh.parseGitFileName(0,
fh.buf.length)); fh.buf.length));
assertEquals(name, fh.getOldName()); assertEquals(name, fh.getOldPath());
assertSame(fh.getOldName(), fh.getNewName()); assertSame(fh.getOldPath(), fh.getNewPath());
assertFalse(fh.hasMetaDataChanges()); assertFalse(fh.hasMetaDataChanges());
} }
@ -139,8 +139,8 @@ public class FileHeaderTest extends TestCase {
final String header = "project-v-1.0/" + name + " mydev/" + name + "\n"; final String header = "project-v-1.0/" + name + " mydev/" + name + "\n";
final FileHeader fh = data(header + "-"); final FileHeader fh = data(header + "-");
assertEquals(header.length(), fh.parseGitFileName(0, fh.buf.length)); assertEquals(header.length(), fh.parseGitFileName(0, fh.buf.length));
assertEquals(name, fh.getOldName()); assertEquals(name, fh.getOldPath());
assertSame(fh.getOldName(), fh.getNewName()); assertSame(fh.getOldPath(), fh.getNewPath());
assertFalse(fh.hasMetaDataChanges()); assertFalse(fh.hasMetaDataChanges());
} }
@ -153,9 +153,9 @@ public class FileHeaderTest extends TestCase {
+ "@@ -0,0 +1 @@\n" + "+a\n"); + "@@ -0,0 +1 @@\n" + "+a\n");
assertParse(fh); assertParse(fh);
assertEquals("/dev/null", fh.getOldName()); assertEquals("/dev/null", fh.getOldPath());
assertSame(DiffEntry.DEV_NULL, fh.getOldName()); assertSame(DiffEntry.DEV_NULL, fh.getOldPath());
assertEquals("\u00c5ngstr\u00f6m", fh.getNewName()); assertEquals("\u00c5ngstr\u00f6m", fh.getNewPath());
assertSame(FileHeader.ChangeType.ADD, fh.getChangeType()); assertSame(FileHeader.ChangeType.ADD, fh.getChangeType());
assertSame(FileHeader.PatchType.UNIFIED, fh.getPatchType()); assertSame(FileHeader.PatchType.UNIFIED, fh.getPatchType());
@ -178,9 +178,9 @@ public class FileHeaderTest extends TestCase {
+ "@@ -1 +0,0 @@\n" + "-a\n"); + "@@ -1 +0,0 @@\n" + "-a\n");
assertParse(fh); assertParse(fh);
assertEquals("\u00c5ngstr\u00f6m", fh.getOldName()); assertEquals("\u00c5ngstr\u00f6m", fh.getOldPath());
assertEquals("/dev/null", fh.getNewName()); assertEquals("/dev/null", fh.getNewPath());
assertSame(DiffEntry.DEV_NULL, fh.getNewName()); assertSame(DiffEntry.DEV_NULL, fh.getNewPath());
assertSame(FileHeader.ChangeType.DELETE, fh.getChangeType()); assertSame(FileHeader.ChangeType.DELETE, fh.getChangeType());
assertSame(FileHeader.PatchType.UNIFIED, fh.getPatchType()); assertSame(FileHeader.PatchType.UNIFIED, fh.getPatchType());
@ -198,8 +198,8 @@ public class FileHeaderTest extends TestCase {
final FileHeader fh = data("diff --git a/a b b/a b\n" final FileHeader fh = data("diff --git a/a b b/a b\n"
+ "old mode 100644\n" + "new mode 100755\n"); + "old mode 100644\n" + "new mode 100755\n");
assertParse(fh); assertParse(fh);
assertEquals("a b", fh.getOldName()); assertEquals("a b", fh.getOldPath());
assertEquals("a b", fh.getNewName()); assertEquals("a b", fh.getNewPath());
assertSame(FileHeader.ChangeType.MODIFY, fh.getChangeType()); assertSame(FileHeader.ChangeType.MODIFY, fh.getChangeType());
assertSame(FileHeader.PatchType.UNIFIED, fh.getPatchType()); assertSame(FileHeader.PatchType.UNIFIED, fh.getPatchType());
@ -220,14 +220,14 @@ public class FileHeaderTest extends TestCase {
+ "rename to \" c/\\303\\205ngstr\\303\\266m\"\n"); + "rename to \" c/\\303\\205ngstr\\303\\266m\"\n");
int ptr = fh.parseGitFileName(0, fh.buf.length); int ptr = fh.parseGitFileName(0, fh.buf.length);
assertTrue(ptr > 0); assertTrue(ptr > 0);
assertNull(fh.getOldName()); // can't parse names on a rename assertNull(fh.getOldPath()); // can't parse names on a rename
assertNull(fh.getNewName()); assertNull(fh.getNewPath());
ptr = fh.parseGitHeaders(ptr, fh.buf.length); ptr = fh.parseGitHeaders(ptr, fh.buf.length);
assertTrue(ptr > 0); assertTrue(ptr > 0);
assertEquals("a", fh.getOldName()); assertEquals("a", fh.getOldPath());
assertEquals(" c/\u00c5ngstr\u00f6m", fh.getNewName()); assertEquals(" c/\u00c5ngstr\u00f6m", fh.getNewPath());
assertSame(FileHeader.ChangeType.RENAME, fh.getChangeType()); assertSame(FileHeader.ChangeType.RENAME, fh.getChangeType());
assertSame(FileHeader.PatchType.UNIFIED, fh.getPatchType()); assertSame(FileHeader.PatchType.UNIFIED, fh.getPatchType());
@ -249,14 +249,14 @@ public class FileHeaderTest extends TestCase {
+ "rename new \" c/\\303\\205ngstr\\303\\266m\"\n"); + "rename new \" c/\\303\\205ngstr\\303\\266m\"\n");
int ptr = fh.parseGitFileName(0, fh.buf.length); int ptr = fh.parseGitFileName(0, fh.buf.length);
assertTrue(ptr > 0); assertTrue(ptr > 0);
assertNull(fh.getOldName()); // can't parse names on a rename assertNull(fh.getOldPath()); // can't parse names on a rename
assertNull(fh.getNewName()); assertNull(fh.getNewPath());
ptr = fh.parseGitHeaders(ptr, fh.buf.length); ptr = fh.parseGitHeaders(ptr, fh.buf.length);
assertTrue(ptr > 0); assertTrue(ptr > 0);
assertEquals("a", fh.getOldName()); assertEquals("a", fh.getOldPath());
assertEquals(" c/\u00c5ngstr\u00f6m", fh.getNewName()); assertEquals(" c/\u00c5ngstr\u00f6m", fh.getNewPath());
assertSame(FileHeader.ChangeType.RENAME, fh.getChangeType()); assertSame(FileHeader.ChangeType.RENAME, fh.getChangeType());
assertSame(FileHeader.PatchType.UNIFIED, fh.getPatchType()); assertSame(FileHeader.PatchType.UNIFIED, fh.getPatchType());
@ -278,14 +278,14 @@ public class FileHeaderTest extends TestCase {
+ "copy to \" c/\\303\\205ngstr\\303\\266m\"\n"); + "copy to \" c/\\303\\205ngstr\\303\\266m\"\n");
int ptr = fh.parseGitFileName(0, fh.buf.length); int ptr = fh.parseGitFileName(0, fh.buf.length);
assertTrue(ptr > 0); assertTrue(ptr > 0);
assertNull(fh.getOldName()); // can't parse names on a copy assertNull(fh.getOldPath()); // can't parse names on a copy
assertNull(fh.getNewName()); assertNull(fh.getNewPath());
ptr = fh.parseGitHeaders(ptr, fh.buf.length); ptr = fh.parseGitHeaders(ptr, fh.buf.length);
assertTrue(ptr > 0); assertTrue(ptr > 0);
assertEquals("a", fh.getOldName()); assertEquals("a", fh.getOldPath());
assertEquals(" c/\u00c5ngstr\u00f6m", fh.getNewName()); assertEquals(" c/\u00c5ngstr\u00f6m", fh.getNewPath());
assertSame(FileHeader.ChangeType.COPY, fh.getChangeType()); assertSame(FileHeader.ChangeType.COPY, fh.getChangeType());
assertSame(FileHeader.PatchType.UNIFIED, fh.getPatchType()); assertSame(FileHeader.PatchType.UNIFIED, fh.getPatchType());
@ -307,8 +307,8 @@ public class FileHeaderTest extends TestCase {
+ ".." + nid + " 100644\n" + "--- a/a\n" + "+++ b/a\n"); + ".." + nid + " 100644\n" + "--- a/a\n" + "+++ b/a\n");
assertParse(fh); assertParse(fh);
assertEquals("a", fh.getOldName()); assertEquals("a", fh.getOldPath());
assertEquals("a", fh.getNewName()); assertEquals("a", fh.getNewPath());
assertSame(FileMode.REGULAR_FILE, fh.getOldMode()); assertSame(FileMode.REGULAR_FILE, fh.getOldMode());
assertSame(FileMode.REGULAR_FILE, fh.getNewMode()); assertSame(FileMode.REGULAR_FILE, fh.getNewMode());
@ -331,8 +331,8 @@ public class FileHeaderTest extends TestCase {
+ ".." + nid + "\n" + "--- a/a\n" + "+++ b/a\n"); + ".." + nid + "\n" + "--- a/a\n" + "+++ b/a\n");
assertParse(fh); assertParse(fh);
assertEquals("a", fh.getOldName()); assertEquals("a", fh.getOldPath());
assertEquals("a", fh.getNewName()); assertEquals("a", fh.getNewPath());
assertFalse(fh.hasMetaDataChanges()); assertFalse(fh.hasMetaDataChanges());
assertNull(fh.getOldMode()); assertNull(fh.getOldMode());
@ -357,8 +357,8 @@ public class FileHeaderTest extends TestCase {
+ " 100644\n" + "--- a/a\n" + "+++ b/a\n"); + " 100644\n" + "--- a/a\n" + "+++ b/a\n");
assertParse(fh); assertParse(fh);
assertEquals("a", fh.getOldName()); assertEquals("a", fh.getOldPath());
assertEquals("a", fh.getNewName()); assertEquals("a", fh.getNewPath());
assertSame(FileMode.REGULAR_FILE, fh.getOldMode()); assertSame(FileMode.REGULAR_FILE, fh.getOldMode());
assertSame(FileMode.REGULAR_FILE, fh.getNewMode()); assertSame(FileMode.REGULAR_FILE, fh.getNewMode());
@ -386,8 +386,8 @@ public class FileHeaderTest extends TestCase {
+ "\n" + "--- a/a\n" + "+++ b/a\n"); + "\n" + "--- a/a\n" + "+++ b/a\n");
assertParse(fh); assertParse(fh);
assertEquals("a", fh.getOldName()); assertEquals("a", fh.getOldPath());
assertEquals("a", fh.getNewName()); assertEquals("a", fh.getNewPath());
assertNull(fh.getOldMode()); assertNull(fh.getOldMode());
assertNull(fh.getNewMode()); assertNull(fh.getNewMode());

12
org.eclipse.jgit.test/tst/org/eclipse/jgit/patch/PatchCcTest.java

@ -60,8 +60,8 @@ public class PatchCcTest extends TestCase {
final CombinedFileHeader cfh = (CombinedFileHeader) p.getFiles().get(0); final CombinedFileHeader cfh = (CombinedFileHeader) p.getFiles().get(0);
assertEquals("org.spearce.egit.ui/src/org/spearce/egit/ui/UIText.java", assertEquals("org.spearce.egit.ui/src/org/spearce/egit/ui/UIText.java",
cfh.getNewName()); cfh.getNewPath());
assertEquals(cfh.getNewName(), cfh.getOldName()); assertEquals(cfh.getNewPath(), cfh.getOldPath());
assertEquals(98, cfh.startOffset); assertEquals(98, cfh.startOffset);
@ -114,8 +114,8 @@ public class PatchCcTest extends TestCase {
final CombinedFileHeader cfh = (CombinedFileHeader) p.getFiles().get(0); final CombinedFileHeader cfh = (CombinedFileHeader) p.getFiles().get(0);
assertSame(DiffEntry.DEV_NULL, cfh.getOldName()); assertSame(DiffEntry.DEV_NULL, cfh.getOldPath());
assertEquals("d", cfh.getNewName()); assertEquals("d", cfh.getNewPath());
assertEquals(187, cfh.startOffset); assertEquals(187, cfh.startOffset);
@ -168,8 +168,8 @@ public class PatchCcTest extends TestCase {
final CombinedFileHeader cfh = (CombinedFileHeader) p.getFiles().get(0); final CombinedFileHeader cfh = (CombinedFileHeader) p.getFiles().get(0);
assertEquals("a", cfh.getOldName()); assertEquals("a", cfh.getOldPath());
assertSame(DiffEntry.DEV_NULL, cfh.getNewName()); assertSame(DiffEntry.DEV_NULL, cfh.getNewPath());
assertEquals(187, cfh.startOffset); assertEquals(187, cfh.startOffset);

10
org.eclipse.jgit.test/tst/org/eclipse/jgit/patch/PatchErrorTest.java

@ -56,7 +56,7 @@ public class PatchErrorTest extends TestCase {
final FileHeader fh = p.getFiles().get(0); final FileHeader fh = p.getFiles().get(0);
assertEquals( assertEquals(
"org.eclipse.jgit/src/org/spearce/jgit/lib/RepositoryConfig.java", "org.eclipse.jgit/src/org/spearce/jgit/lib/RepositoryConfig.java",
fh.getNewName()); fh.getNewPath());
assertEquals(1, fh.getHunks().size()); assertEquals(1, fh.getHunks().size());
} }
@ -114,14 +114,14 @@ public class PatchErrorTest extends TestCase {
final FileHeader fh = p.getFiles().get(0); final FileHeader fh = p.getFiles().get(0);
assertEquals( assertEquals(
"org.eclipse.jgit.test/tst/org/spearce/jgit/lib/RepositoryConfigTest.java", "org.eclipse.jgit.test/tst/org/spearce/jgit/lib/RepositoryConfigTest.java",
fh.getNewName()); fh.getNewPath());
assertEquals(1, fh.getHunks().size()); assertEquals(1, fh.getHunks().size());
} }
{ {
final FileHeader fh = p.getFiles().get(1); final FileHeader fh = p.getFiles().get(1);
assertEquals( assertEquals(
"org.eclipse.jgit/src/org/spearce/jgit/lib/RepositoryConfig.java", "org.eclipse.jgit/src/org/spearce/jgit/lib/RepositoryConfig.java",
fh.getNewName()); fh.getNewPath());
assertEquals(1, fh.getHunks().size()); assertEquals(1, fh.getHunks().size());
} }
@ -139,7 +139,7 @@ public class PatchErrorTest extends TestCase {
{ {
final FileHeader fh = p.getFiles().get(0); final FileHeader fh = p.getFiles().get(0);
assertEquals("org.spearce.egit.ui/icons/toolbar/fetchd.png", fh assertEquals("org.spearce.egit.ui/icons/toolbar/fetchd.png", fh
.getNewName()); .getNewPath());
assertSame(FileHeader.PatchType.GIT_BINARY, fh.getPatchType()); assertSame(FileHeader.PatchType.GIT_BINARY, fh.getPatchType());
assertTrue(fh.getHunks().isEmpty()); assertTrue(fh.getHunks().isEmpty());
assertNull(fh.getForwardBinaryHunk()); assertNull(fh.getForwardBinaryHunk());
@ -147,7 +147,7 @@ public class PatchErrorTest extends TestCase {
{ {
final FileHeader fh = p.getFiles().get(1); final FileHeader fh = p.getFiles().get(1);
assertEquals("org.spearce.egit.ui/icons/toolbar/fetche.png", fh assertEquals("org.spearce.egit.ui/icons/toolbar/fetche.png", fh
.getNewName()); .getNewPath());
assertSame(FileHeader.PatchType.UNIFIED, fh.getPatchType()); assertSame(FileHeader.PatchType.UNIFIED, fh.getPatchType());
assertTrue(fh.getHunks().isEmpty()); assertTrue(fh.getHunks().isEmpty());
assertNull(fh.getForwardBinaryHunk()); assertNull(fh.getForwardBinaryHunk());

18
org.eclipse.jgit.test/tst/org/eclipse/jgit/patch/PatchTest.java

@ -68,11 +68,11 @@ public class PatchTest extends TestCase {
assertEquals( assertEquals(
"org.eclipse.jgit.test/tst/org/spearce/jgit/lib/RepositoryConfigTest.java", "org.eclipse.jgit.test/tst/org/spearce/jgit/lib/RepositoryConfigTest.java",
fRepositoryConfigTest.getNewName()); fRepositoryConfigTest.getNewPath());
assertEquals( assertEquals(
"org.eclipse.jgit/src/org/spearce/jgit/lib/RepositoryConfig.java", "org.eclipse.jgit/src/org/spearce/jgit/lib/RepositoryConfig.java",
fRepositoryConfig.getNewName()); fRepositoryConfig.getNewPath());
assertEquals(572, fRepositoryConfigTest.startOffset); assertEquals(572, fRepositoryConfigTest.startOffset);
assertEquals(1490, fRepositoryConfig.startOffset); assertEquals(1490, fRepositoryConfig.startOffset);
@ -168,7 +168,7 @@ public class PatchTest extends TestCase {
assertEquals("0000000", fh.getOldId().name()); assertEquals("0000000", fh.getOldId().name());
assertSame(FileMode.MISSING, fh.getOldMode()); assertSame(FileMode.MISSING, fh.getOldMode());
assertSame(FileMode.REGULAR_FILE, fh.getNewMode()); assertSame(FileMode.REGULAR_FILE, fh.getNewMode());
assertTrue(fh.getNewName().startsWith( assertTrue(fh.getNewPath().startsWith(
"org.spearce.egit.ui/icons/toolbar/")); "org.spearce.egit.ui/icons/toolbar/"));
assertSame(FileHeader.PatchType.BINARY, fh.getPatchType()); assertSame(FileHeader.PatchType.BINARY, fh.getPatchType());
assertTrue(fh.getHunks().isEmpty()); assertTrue(fh.getHunks().isEmpty());
@ -179,7 +179,7 @@ public class PatchTest extends TestCase {
} }
final FileHeader fh = p.getFiles().get(4); final FileHeader fh = p.getFiles().get(4);
assertEquals("org.spearce.egit.ui/plugin.xml", fh.getNewName()); assertEquals("org.spearce.egit.ui/plugin.xml", fh.getNewPath());
assertSame(FileHeader.ChangeType.MODIFY, fh.getChangeType()); assertSame(FileHeader.ChangeType.MODIFY, fh.getChangeType());
assertSame(FileHeader.PatchType.UNIFIED, fh.getPatchType()); assertSame(FileHeader.PatchType.UNIFIED, fh.getPatchType());
assertFalse(fh.hasMetaDataChanges()); assertFalse(fh.hasMetaDataChanges());
@ -203,7 +203,7 @@ public class PatchTest extends TestCase {
assertNotNull(fh.getNewId()); assertNotNull(fh.getNewId());
assertEquals(ObjectId.zeroId().name(), fh.getOldId().name()); assertEquals(ObjectId.zeroId().name(), fh.getOldId().name());
assertSame(FileMode.REGULAR_FILE, fh.getNewMode()); assertSame(FileMode.REGULAR_FILE, fh.getNewMode());
assertTrue(fh.getNewName().startsWith( assertTrue(fh.getNewPath().startsWith(
"org.spearce.egit.ui/icons/toolbar/")); "org.spearce.egit.ui/icons/toolbar/"));
assertSame(FileHeader.PatchType.GIT_BINARY, fh.getPatchType()); assertSame(FileHeader.PatchType.GIT_BINARY, fh.getPatchType());
assertTrue(fh.getHunks().isEmpty()); assertTrue(fh.getHunks().isEmpty());
@ -224,7 +224,7 @@ public class PatchTest extends TestCase {
} }
final FileHeader fh = p.getFiles().get(4); final FileHeader fh = p.getFiles().get(4);
assertEquals("org.spearce.egit.ui/plugin.xml", fh.getNewName()); assertEquals("org.spearce.egit.ui/plugin.xml", fh.getNewPath());
assertSame(FileHeader.ChangeType.MODIFY, fh.getChangeType()); assertSame(FileHeader.ChangeType.MODIFY, fh.getChangeType());
assertSame(FileHeader.PatchType.UNIFIED, fh.getPatchType()); assertSame(FileHeader.PatchType.UNIFIED, fh.getPatchType());
assertFalse(fh.hasMetaDataChanges()); assertFalse(fh.hasMetaDataChanges());
@ -241,7 +241,7 @@ public class PatchTest extends TestCase {
assertTrue(p.getErrors().isEmpty()); assertTrue(p.getErrors().isEmpty());
final FileHeader fh = p.getFiles().get(0); final FileHeader fh = p.getFiles().get(0);
assertTrue(fh.getNewName().startsWith("zero.bin")); assertTrue(fh.getNewPath().startsWith("zero.bin"));
assertSame(FileHeader.ChangeType.MODIFY, fh.getChangeType()); assertSame(FileHeader.ChangeType.MODIFY, fh.getChangeType());
assertSame(FileHeader.PatchType.GIT_BINARY, fh.getPatchType()); assertSame(FileHeader.PatchType.GIT_BINARY, fh.getPatchType());
assertSame(FileMode.REGULAR_FILE, fh.getNewMode()); assertSame(FileMode.REGULAR_FILE, fh.getNewMode());
@ -279,7 +279,7 @@ public class PatchTest extends TestCase {
final FileHeader f = p.getFiles().get(0); final FileHeader f = p.getFiles().get(0);
assertEquals("a", f.getNewName()); assertEquals("a", f.getNewPath());
assertEquals(252, f.startOffset); assertEquals(252, f.startOffset);
assertEquals("2e65efe", f.getOldId().name()); assertEquals("2e65efe", f.getOldId().name());
@ -313,7 +313,7 @@ public class PatchTest extends TestCase {
final FileHeader f = p.getFiles().get(0); final FileHeader f = p.getFiles().get(0);
assertEquals("a", f.getNewName()); assertEquals("a", f.getNewPath());
assertEquals(256, f.startOffset); assertEquals(256, f.startOffset);
assertEquals("f2ad6c7", f.getOldId().name()); assertEquals("f2ad6c7", f.getOldId().name());

62
org.eclipse.jgit/src/org/eclipse/jgit/diff/DiffEntry.java

@ -112,15 +112,15 @@ public class DiffEntry {
entry.oldMode = walk.getFileMode(0); entry.oldMode = walk.getFileMode(0);
entry.newMode = walk.getFileMode(1); entry.newMode = walk.getFileMode(1);
entry.newName = entry.oldName = walk.getPathString(); entry.newPath = entry.oldPath = walk.getPathString();
if (entry.oldMode == FileMode.MISSING) { if (entry.oldMode == FileMode.MISSING) {
entry.oldName = DiffEntry.DEV_NULL; entry.oldPath = DiffEntry.DEV_NULL;
entry.changeType = ChangeType.ADD; entry.changeType = ChangeType.ADD;
r.add(entry); r.add(entry);
} else if (entry.newMode == FileMode.MISSING) { } else if (entry.newMode == FileMode.MISSING) {
entry.newName = DiffEntry.DEV_NULL; entry.newPath = DiffEntry.DEV_NULL;
entry.changeType = ChangeType.DELETE; entry.changeType = ChangeType.DELETE;
r.add(entry); r.add(entry);
@ -139,11 +139,11 @@ public class DiffEntry {
DiffEntry e = new DiffEntry(); DiffEntry e = new DiffEntry();
e.oldId = A_ZERO; e.oldId = A_ZERO;
e.oldMode = FileMode.MISSING; e.oldMode = FileMode.MISSING;
e.oldName = DEV_NULL; e.oldPath = DEV_NULL;
e.newId = AbbreviatedObjectId.fromObjectId(id); e.newId = AbbreviatedObjectId.fromObjectId(id);
e.newMode = FileMode.REGULAR_FILE; e.newMode = FileMode.REGULAR_FILE;
e.newName = path; e.newPath = path;
e.changeType = ChangeType.ADD; e.changeType = ChangeType.ADD;
return e; return e;
} }
@ -152,11 +152,11 @@ public class DiffEntry {
DiffEntry e = new DiffEntry(); DiffEntry e = new DiffEntry();
e.oldId = AbbreviatedObjectId.fromObjectId(id); e.oldId = AbbreviatedObjectId.fromObjectId(id);
e.oldMode = FileMode.REGULAR_FILE; e.oldMode = FileMode.REGULAR_FILE;
e.oldName = path; e.oldPath = path;
e.newId = A_ZERO; e.newId = A_ZERO;
e.newMode = FileMode.MISSING; e.newMode = FileMode.MISSING;
e.newName = DEV_NULL; e.newPath = DEV_NULL;
e.changeType = ChangeType.DELETE; e.changeType = ChangeType.DELETE;
return e; return e;
} }
@ -164,10 +164,10 @@ public class DiffEntry {
static DiffEntry modify(String path) { static DiffEntry modify(String path) {
DiffEntry e = new DiffEntry(); DiffEntry e = new DiffEntry();
e.oldMode = FileMode.REGULAR_FILE; e.oldMode = FileMode.REGULAR_FILE;
e.oldName = path; e.oldPath = path;
e.newMode = FileMode.REGULAR_FILE; e.newMode = FileMode.REGULAR_FILE;
e.newName = path; e.newPath = path;
e.changeType = ChangeType.MODIFY; e.changeType = ChangeType.MODIFY;
return e; return e;
} }
@ -185,21 +185,21 @@ public class DiffEntry {
DiffEntry del = new DiffEntry(); DiffEntry del = new DiffEntry();
del.oldId = entry.getOldId(); del.oldId = entry.getOldId();
del.oldMode = entry.getOldMode(); del.oldMode = entry.getOldMode();
del.oldName = entry.getOldName(); del.oldPath = entry.getOldPath();
del.newId = A_ZERO; del.newId = A_ZERO;
del.newMode = FileMode.MISSING; del.newMode = FileMode.MISSING;
del.newName = DiffEntry.DEV_NULL; del.newPath = DiffEntry.DEV_NULL;
del.changeType = ChangeType.DELETE; del.changeType = ChangeType.DELETE;
DiffEntry add = new DiffEntry(); DiffEntry add = new DiffEntry();
add.oldId = A_ZERO; add.oldId = A_ZERO;
add.oldMode = FileMode.MISSING; add.oldMode = FileMode.MISSING;
add.oldName = DiffEntry.DEV_NULL; add.oldPath = DiffEntry.DEV_NULL;
add.newId = entry.getNewId(); add.newId = entry.getNewId();
add.newMode = entry.getNewMode(); add.newMode = entry.getNewMode();
add.newName = entry.getNewName(); add.newPath = entry.getNewPath();
add.changeType = ChangeType.ADD; add.changeType = ChangeType.ADD;
return Arrays.asList(del, add); return Arrays.asList(del, add);
} }
@ -210,11 +210,11 @@ public class DiffEntry {
r.oldId = src.oldId; r.oldId = src.oldId;
r.oldMode = src.oldMode; r.oldMode = src.oldMode;
r.oldName = src.oldName; r.oldPath = src.oldPath;
r.newId = dst.newId; r.newId = dst.newId;
r.newMode = dst.newMode; r.newMode = dst.newMode;
r.newName = dst.newName; r.newPath = dst.newPath;
r.changeType = changeType; r.changeType = changeType;
r.score = score; r.score = score;
@ -223,10 +223,10 @@ public class DiffEntry {
} }
/** File name of the old (pre-image). */ /** File name of the old (pre-image). */
protected String oldName; protected String oldPath;
/** File name of the new (post-image). */ /** File name of the new (post-image). */
protected String newName; protected String newPath;
/** Old mode of the file, if described by the patch, else null. */ /** Old mode of the file, if described by the patch, else null. */
protected FileMode oldMode; protected FileMode oldMode;
@ -253,7 +253,7 @@ public class DiffEntry {
* of this patch: * of this patch:
* <ul> * <ul>
* <li><i>file add</i>: always <code>/dev/null</code></li> * <li><i>file add</i>: always <code>/dev/null</code></li>
* <li><i>file modify</i>: always {@link #getNewName()}</li> * <li><i>file modify</i>: always {@link #getNewPath()}</li>
* <li><i>file delete</i>: always the file being deleted</li> * <li><i>file delete</i>: always the file being deleted</li>
* <li><i>file copy</i>: source file the copy originates from</li> * <li><i>file copy</i>: source file the copy originates from</li>
* <li><i>file rename</i>: source file the rename originates from</li> * <li><i>file rename</i>: source file the rename originates from</li>
@ -261,8 +261,8 @@ public class DiffEntry {
* *
* @return old name for this file. * @return old name for this file.
*/ */
public String getOldName() { public String getOldPath() {
return oldName; return oldPath;
} }
/** /**
@ -272,7 +272,7 @@ public class DiffEntry {
* of this patch: * of this patch:
* <ul> * <ul>
* <li><i>file add</i>: always the file being created</li> * <li><i>file add</i>: always the file being created</li>
* <li><i>file modify</i>: always {@link #getOldName()}</li> * <li><i>file modify</i>: always {@link #getOldPath()}</li>
* <li><i>file delete</i>: always <code>/dev/null</code></li> * <li><i>file delete</i>: always <code>/dev/null</code></li>
* <li><i>file copy</i>: destination file the copy ends up at</li> * <li><i>file copy</i>: destination file the copy ends up at</li>
* <li><i>file rename</i>: destination file the rename ends up at/li> * <li><i>file rename</i>: destination file the rename ends up at/li>
@ -280,8 +280,8 @@ public class DiffEntry {
* *
* @return new name for this file. * @return new name for this file.
*/ */
public String getNewName() { public String getNewPath() {
return newName; return newPath;
} }
/** @return the old file mode, if described in the patch */ /** @return the old file mode, if described in the patch */
@ -294,14 +294,14 @@ public class DiffEntry {
return newMode; return newMode;
} }
/** @return the type of change this patch makes on {@link #getNewName()} */ /** @return the type of change this patch makes on {@link #getNewPath()} */
public ChangeType getChangeType() { public ChangeType getChangeType() {
return changeType; return changeType;
} }
/** /**
* @return similarity score between {@link #getOldName()} and * @return similarity score between {@link #getOldPath()} and
* {@link #getNewName()} if {@link #getChangeType()} is * {@link #getNewPath()} if {@link #getChangeType()} is
* {@link ChangeType#COPY} or {@link ChangeType#RENAME}. * {@link ChangeType#COPY} or {@link ChangeType#RENAME}.
*/ */
public int getScore() { public int getScore() {
@ -334,19 +334,19 @@ public class DiffEntry {
buf.append(" "); buf.append(" ");
switch (changeType) { switch (changeType) {
case ADD: case ADD:
buf.append(newName); buf.append(newPath);
break; break;
case COPY: case COPY:
buf.append(oldName + "->" + newName); buf.append(oldPath + "->" + newPath);
break; break;
case DELETE: case DELETE:
buf.append(oldName); buf.append(oldPath);
break; break;
case MODIFY: case MODIFY:
buf.append(oldName); buf.append(oldPath);
break; break;
case RENAME: case RENAME:
buf.append(oldName + "->" + newName); buf.append(oldPath + "->" + newPath);
break; break;
} }
buf.append("]"); buf.append("]");

12
org.eclipse.jgit/src/org/eclipse/jgit/diff/DiffFormatter.java

@ -246,8 +246,8 @@ public class DiffFormatter {
private void writeDiffHeader(OutputStream o, DiffEntry ent) private void writeDiffHeader(OutputStream o, DiffEntry ent)
throws IOException { throws IOException {
String oldName = quotePath("a/" + ent.getOldName()); String oldName = quotePath("a/" + ent.getOldPath());
String newName = quotePath("b/" + ent.getNewName()); String newName = quotePath("b/" + ent.getNewPath());
o.write(encode("diff --git " + oldName + " " + newName + "\n")); o.write(encode("diff --git " + oldName + " " + newName + "\n"));
switch (ent.getChangeType()) { switch (ent.getChangeType()) {
@ -267,10 +267,10 @@ public class DiffFormatter {
o.write(encodeASCII("similarity index " + ent.getScore() + "%")); o.write(encodeASCII("similarity index " + ent.getScore() + "%"));
o.write('\n'); o.write('\n');
o.write(encode("rename from " + quotePath(ent.getOldName()))); o.write(encode("rename from " + quotePath(ent.getOldPath())));
o.write('\n'); o.write('\n');
o.write(encode("rename to " + quotePath(ent.getNewName()))); o.write(encode("rename to " + quotePath(ent.getNewPath())));
o.write('\n'); o.write('\n');
break; break;
@ -278,10 +278,10 @@ public class DiffFormatter {
o.write(encodeASCII("similarity index " + ent.getScore() + "%")); o.write(encodeASCII("similarity index " + ent.getScore() + "%"));
o.write('\n'); o.write('\n');
o.write(encode("copy from " + quotePath(ent.getOldName()))); o.write(encode("copy from " + quotePath(ent.getOldPath())));
o.write('\n'); o.write('\n');
o.write(encode("copy to " + quotePath(ent.getNewName()))); o.write(encode("copy to " + quotePath(ent.getNewPath())));
o.write('\n'); o.write('\n');
if (!ent.getOldMode().equals(ent.getNewMode())) { if (!ent.getOldMode().equals(ent.getNewMode())) {

16
org.eclipse.jgit/src/org/eclipse/jgit/diff/RenameDetector.java

@ -80,8 +80,8 @@ public class RenameDetector {
// the old name. // the old name.
// //
if (ent.changeType == ChangeType.DELETE) if (ent.changeType == ChangeType.DELETE)
return ent.oldName; return ent.oldPath;
return ent.newName; return ent.newPath;
} }
private int sortOf(ChangeType changeType) { private int sortOf(ChangeType changeType) {
@ -369,18 +369,18 @@ public class RenameDetector {
+ deleted.size()); + deleted.size());
for (DiffEntry src : deleted) { for (DiffEntry src : deleted) {
nameMap.put(src.oldName, src); nameMap.put(src.oldPath, src);
pm.update(1); pm.update(1);
} }
for (DiffEntry dst : added) { for (DiffEntry dst : added) {
DiffEntry src = nameMap.remove(dst.newName); DiffEntry src = nameMap.remove(dst.newPath);
if (src != null) { if (src != null) {
if (sameType(src.oldMode, dst.newMode)) { if (sameType(src.oldMode, dst.newMode)) {
entries.add(DiffEntry.pair(ChangeType.MODIFY, src, dst, entries.add(DiffEntry.pair(ChangeType.MODIFY, src, dst,
src.score)); src.score));
} else { } else {
nameMap.put(src.oldName, src); nameMap.put(src.oldPath, src);
newAdded.add(dst); newAdded.add(dst);
} }
} else { } else {
@ -509,10 +509,10 @@ public class RenameDetector {
long[] matrix = new long[dels.size() * adds.size()]; long[] matrix = new long[dels.size() * adds.size()];
int mNext = 0; int mNext = 0;
for (int addIdx = 0; addIdx < adds.size(); addIdx++) { for (int addIdx = 0; addIdx < adds.size(); addIdx++) {
String addedName = adds.get(addIdx).newName; String addedName = adds.get(addIdx).newPath;
for (int delIdx = 0; delIdx < dels.size(); delIdx++) { for (int delIdx = 0; delIdx < dels.size(); delIdx++) {
String deletedName = dels.get(delIdx).oldName; String deletedName = dels.get(delIdx).oldPath;
int score = SimilarityRenameDetector.nameScore(addedName, deletedName); int score = SimilarityRenameDetector.nameScore(addedName, deletedName);
matrix[mNext] = SimilarityRenameDetector.encode(score, addIdx, delIdx); matrix[mNext] = SimilarityRenameDetector.encode(score, addIdx, delIdx);
@ -625,7 +625,7 @@ public class RenameDetector {
} }
private static String path(DiffEntry de) { private static String path(DiffEntry de) {
return de.changeType == ChangeType.DELETE ? de.oldName : de.newName; return de.changeType == ChangeType.DELETE ? de.oldPath : de.newPath;
} }
private static FileMode mode(DiffEntry de) { private static FileMode mode(DiffEntry de) {

2
org.eclipse.jgit/src/org/eclipse/jgit/diff/SimilarityRenameDetector.java

@ -266,7 +266,7 @@ class SimilarityRenameDetector {
// nameScore returns a value between 0 and 100, but we want it // nameScore returns a value between 0 and 100, but we want it
// to be in the same range as the content score. This allows it // to be in the same range as the content score. This allows it
// to be dropped into the pretty formula for the final score. // to be dropped into the pretty formula for the final score.
int nameScore = nameScore(srcEnt.oldName, dstEnt.newName) * 100; int nameScore = nameScore(srcEnt.oldPath, dstEnt.newPath) * 100;
int score = (contentScore * 99 + nameScore * 1) / 10000; int score = (contentScore * 99 + nameScore * 1) / 10000;

28
org.eclipse.jgit/src/org/eclipse/jgit/patch/FileHeader.java

@ -385,12 +385,12 @@ public class FileHeader extends DiffEntry {
if (buf[sp - 2] != '"') { if (buf[sp - 2] != '"') {
return eol; return eol;
} }
oldName = QuotedString.GIT_PATH.dequote(buf, bol, sp - 1); oldPath = QuotedString.GIT_PATH.dequote(buf, bol, sp - 1);
oldName = p1(oldName); oldPath = p1(oldPath);
} else { } else {
oldName = decode(Constants.CHARSET, buf, aStart, sp - 1); oldPath = decode(Constants.CHARSET, buf, aStart, sp - 1);
} }
newName = oldName; newPath = oldPath;
return eol; return eol;
} }
@ -431,27 +431,27 @@ public class FileHeader extends DiffEntry {
parseNewFileMode(ptr, eol); parseNewFileMode(ptr, eol);
} else if (match(buf, ptr, COPY_FROM) >= 0) { } else if (match(buf, ptr, COPY_FROM) >= 0) {
oldName = parseName(oldName, ptr + COPY_FROM.length, eol); oldPath = parseName(oldPath, ptr + COPY_FROM.length, eol);
changeType = ChangeType.COPY; changeType = ChangeType.COPY;
} else if (match(buf, ptr, COPY_TO) >= 0) { } else if (match(buf, ptr, COPY_TO) >= 0) {
newName = parseName(newName, ptr + COPY_TO.length, eol); newPath = parseName(newPath, ptr + COPY_TO.length, eol);
changeType = ChangeType.COPY; changeType = ChangeType.COPY;
} else if (match(buf, ptr, RENAME_OLD) >= 0) { } else if (match(buf, ptr, RENAME_OLD) >= 0) {
oldName = parseName(oldName, ptr + RENAME_OLD.length, eol); oldPath = parseName(oldPath, ptr + RENAME_OLD.length, eol);
changeType = ChangeType.RENAME; changeType = ChangeType.RENAME;
} else if (match(buf, ptr, RENAME_NEW) >= 0) { } else if (match(buf, ptr, RENAME_NEW) >= 0) {
newName = parseName(newName, ptr + RENAME_NEW.length, eol); newPath = parseName(newPath, ptr + RENAME_NEW.length, eol);
changeType = ChangeType.RENAME; changeType = ChangeType.RENAME;
} else if (match(buf, ptr, RENAME_FROM) >= 0) { } else if (match(buf, ptr, RENAME_FROM) >= 0) {
oldName = parseName(oldName, ptr + RENAME_FROM.length, eol); oldPath = parseName(oldPath, ptr + RENAME_FROM.length, eol);
changeType = ChangeType.RENAME; changeType = ChangeType.RENAME;
} else if (match(buf, ptr, RENAME_TO) >= 0) { } else if (match(buf, ptr, RENAME_TO) >= 0) {
newName = parseName(newName, ptr + RENAME_TO.length, eol); newPath = parseName(newPath, ptr + RENAME_TO.length, eol);
changeType = ChangeType.RENAME; changeType = ChangeType.RENAME;
} else if (match(buf, ptr, SIMILARITY_INDEX) >= 0) { } else if (match(buf, ptr, SIMILARITY_INDEX) >= 0) {
@ -474,14 +474,14 @@ public class FileHeader extends DiffEntry {
} }
void parseOldName(int ptr, final int eol) { void parseOldName(int ptr, final int eol) {
oldName = p1(parseName(oldName, ptr + OLD_NAME.length, eol)); oldPath = p1(parseName(oldPath, ptr + OLD_NAME.length, eol));
if (oldName == DEV_NULL) if (oldPath == DEV_NULL)
changeType = ChangeType.ADD; changeType = ChangeType.ADD;
} }
void parseNewName(int ptr, final int eol) { void parseNewName(int ptr, final int eol) {
newName = p1(parseName(newName, ptr + NEW_NAME.length, eol)); newPath = p1(parseName(newPath, ptr + NEW_NAME.length, eol));
if (newName == DEV_NULL) if (newPath == DEV_NULL)
changeType = ChangeType.DELETE; changeType = ChangeType.DELETE;
} }

4
org.eclipse.jgit/src/org/eclipse/jgit/revwalk/RewriteTreeFilter.java

@ -245,8 +245,8 @@ class RewriteTreeFilter extends RevFilter {
TreeFilter newFilter = oldFilter; TreeFilter newFilter = oldFilter;
for (DiffEntry ent : files) { for (DiffEntry ent : files) {
if (isRename(ent) && ent.getNewName().equals(oldFilter.getPath())) { if (isRename(ent) && ent.getNewPath().equals(oldFilter.getPath())) {
newFilter = FollowFilter.create(ent.getOldName()); newFilter = FollowFilter.create(ent.getOldPath());
break; break;
} }
} }

Loading…
Cancel
Save