]> source.dussan.org Git - jgit.git/commitdiff
Reset internal state canonical length in WorkingTreeIterator when moving 32/21432/4
authorRobin Rosenberg <robin.rosenberg@dewire.com>
Sun, 2 Feb 2014 22:26:34 +0000 (23:26 +0100)
committerMatthias Sohn <matthias.sohn@sap.com>
Mon, 3 Feb 2014 13:51:11 +0000 (14:51 +0100)
Bug: 426514
Change-Id: Ifb75a4fa12291aeeece3dda129a65f0c1fd5e0eb
Signed-off-by: Matthias Sohn <matthias.sohn@sap.com>
org.eclipse.jgit.test/tst/org/eclipse/jgit/treewalk/FileTreeIteratorTest.java
org.eclipse.jgit/src/org/eclipse/jgit/treewalk/WorkingTreeIterator.java

index 4ce4c8d04f6b97e1642fd5fbe16cab504778a794..0bd1e9a9209ffa0d75fdd51b5dfcf1c180eb8abe 100644 (file)
@@ -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;
@@ -98,6 +98,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]);
index 280f64f4f0ff0b6dfd4f3e5e0e831bf82484ca45..14c53dd100da53307a60dac1a433ac8c8f67a865 100644 (file)
@@ -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;
        }
 
        /**