Browse Source

Reset internal state canonical length in WorkingTreeIterator when moving

Bug: 426514
Change-Id: Ifb75a4fa12291aeeece3dda129a65f0c1fd5e0eb
Signed-off-by: Matthias Sohn <matthias.sohn@sap.com>
stable-3.3
Robin Rosenberg 11 years ago committed by Matthias Sohn
parent
commit
871ee53b52
  1. 15
      org.eclipse.jgit.test/tst/org/eclipse/jgit/treewalk/FileTreeIteratorTest.java
  2. 2
      org.eclipse.jgit/src/org/eclipse/jgit/treewalk/WorkingTreeIterator.java

15
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.DirCache;
import org.eclipse.jgit.dircache.DirCacheCheckout; import org.eclipse.jgit.dircache.DirCacheCheckout;
import org.eclipse.jgit.dircache.DirCacheEditor; import org.eclipse.jgit.dircache.DirCacheEditor;
import org.eclipse.jgit.dircache.DirCacheEditor.PathEdit;
import org.eclipse.jgit.dircache.DirCacheEntry; import org.eclipse.jgit.dircache.DirCacheEntry;
import org.eclipse.jgit.dircache.DirCacheIterator; import org.eclipse.jgit.dircache.DirCacheIterator;
import org.eclipse.jgit.dircache.DirCacheEditor.PathEdit;
import org.eclipse.jgit.errors.CorruptObjectException; import org.eclipse.jgit.errors.CorruptObjectException;
import org.eclipse.jgit.errors.IncorrectObjectTypeException; import org.eclipse.jgit.errors.IncorrectObjectTypeException;
import org.eclipse.jgit.errors.MissingObjectException; 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 @Test
public void testEmptyIfRootIsFile() throws Exception { public void testEmptyIfRootIsFile() throws Exception {
final File r = new File(trash, paths[0]); final File r = new File(trash, paths[0]);

2
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 { public void next(final int delta) throws CorruptObjectException {
ptr += delta; ptr += delta;
if (!eof()) { if (!eof()) {
canonLen = -1;
parseEntry(); parseEntry();
} }
} }
@ -484,6 +483,7 @@ public abstract class WorkingTreeIterator extends AbstractTreeIterator {
ensurePathCapacity(pathOffset + nameLen, pathOffset); ensurePathCapacity(pathOffset + nameLen, pathOffset);
System.arraycopy(e.encodedName, 0, path, pathOffset, nameLen); System.arraycopy(e.encodedName, 0, path, pathOffset, nameLen);
pathLen = pathOffset + nameLen; pathLen = pathOffset + nameLen;
canonLen = -1;
} }
/** /**

Loading…
Cancel
Save