Reset internal state canonical length in WorkingTreeIterator when moving

Bug: 426514
Change-Id: Ifb75a4fa12291aeeece3dda129a65f0c1fd5e0eb
Signed-off-by: Matthias Sohn <matthias.sohn@sap.com>
This commit is contained in:
Robin Rosenberg 2014-02-02 23:26:34 +01:00 committed by Matthias Sohn
parent 5404e70dc6
commit 871ee53b52
2 changed files with 15 additions and 2 deletions

View File

@ -56,9 +56,9 @@
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 void setUp() throws Exception {
}
}
@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]);

View File

@ -465,7 +465,6 @@ public boolean eof() {
public void next(final int delta) throws CorruptObjectException {
ptr += delta;
if (!eof()) {
canonLen = -1;
parseEntry();
}
}
@ -484,6 +483,7 @@ private void parseEntry() {
ensurePathCapacity(pathOffset + nameLen, pathOffset);
System.arraycopy(e.encodedName, 0, path, pathOffset, nameLen);
pathLen = pathOffset + nameLen;
canonLen = -1;
}
/**