summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMatthias Sohn <matthias.sohn@sap.com>2014-02-04 03:03:27 -0500
committerGerrit Code Review @ Eclipse.org <gerrit@eclipse.org>2014-02-04 03:03:27 -0500
commit08fd639c0d8fd1aebf96106b1d2ad67818c7ebd9 (patch)
tree14853d46aed878fe55bf037c3464a01be8330d8a
parent8ae6295007f5247ba90e67bc86875cfecd082756 (diff)
parent871ee53b52a7e7f6a0fe600a054ec78f8e4bff5a (diff)
downloadjgit-08fd639c0d8fd1aebf96106b1d2ad67818c7ebd9.tar.gz
jgit-08fd639c0d8fd1aebf96106b1d2ad67818c7ebd9.zip
Merge "Reset internal state canonical length in WorkingTreeIterator when moving"
-rw-r--r--org.eclipse.jgit.test/tst/org/eclipse/jgit/treewalk/FileTreeIteratorTest.java15
-rw-r--r--org.eclipse.jgit/src/org/eclipse/jgit/treewalk/WorkingTreeIterator.java2
2 files changed, 15 insertions, 2 deletions
diff --git a/org.eclipse.jgit.test/tst/org/eclipse/jgit/treewalk/FileTreeIteratorTest.java b/org.eclipse.jgit.test/tst/org/eclipse/jgit/treewalk/FileTreeIteratorTest.java
index 4ce4c8d04f..0bd1e9a920 100644
--- a/org.eclipse.jgit.test/tst/org/eclipse/jgit/treewalk/FileTreeIteratorTest.java
+++ b/org.eclipse.jgit.test/tst/org/eclipse/jgit/treewalk/FileTreeIteratorTest.java
@@ -56,9 +56,9 @@ import org.eclipse.jgit.api.Git;
import org.eclipse.jgit.dircache.DirCache;
import org.eclipse.jgit.dircache.DirCacheCheckout;
import org.eclipse.jgit.dircache.DirCacheEditor;
+import org.eclipse.jgit.dircache.DirCacheEditor.PathEdit;
import org.eclipse.jgit.dircache.DirCacheEntry;
import org.eclipse.jgit.dircache.DirCacheIterator;
-import org.eclipse.jgit.dircache.DirCacheEditor.PathEdit;
import org.eclipse.jgit.errors.CorruptObjectException;
import org.eclipse.jgit.errors.IncorrectObjectTypeException;
import org.eclipse.jgit.errors.MissingObjectException;
@@ -99,6 +99,19 @@ public class FileTreeIteratorTest extends RepositoryTestCase {
}
@Test
+ public void testGetEntryContentLength() throws Exception {
+ final FileTreeIterator fti = new FileTreeIterator(db);
+ fti.next(1);
+ assertEquals(3, fti.getEntryContentLength());
+ fti.back(1);
+ assertEquals(2, fti.getEntryContentLength());
+ fti.next(1);
+ assertEquals(3, fti.getEntryContentLength());
+ fti.reset();
+ assertEquals(2, fti.getEntryContentLength());
+ }
+
+ @Test
public void testEmptyIfRootIsFile() throws Exception {
final File r = new File(trash, paths[0]);
assertTrue(r.isFile());
diff --git a/org.eclipse.jgit/src/org/eclipse/jgit/treewalk/WorkingTreeIterator.java b/org.eclipse.jgit/src/org/eclipse/jgit/treewalk/WorkingTreeIterator.java
index 280f64f4f0..14c53dd100 100644
--- a/org.eclipse.jgit/src/org/eclipse/jgit/treewalk/WorkingTreeIterator.java
+++ b/org.eclipse.jgit/src/org/eclipse/jgit/treewalk/WorkingTreeIterator.java
@@ -465,7 +465,6 @@ public abstract class WorkingTreeIterator extends AbstractTreeIterator {
public void next(final int delta) throws CorruptObjectException {
ptr += delta;
if (!eof()) {
- canonLen = -1;
parseEntry();
}
}
@@ -484,6 +483,7 @@ public abstract class WorkingTreeIterator extends AbstractTreeIterator {
ensurePathCapacity(pathOffset + nameLen, pathOffset);
System.arraycopy(e.encodedName, 0, path, pathOffset, nameLen);
pathLen = pathOffset + nameLen;
+ canonLen = -1;
}
/**