summaryrefslogtreecommitdiffstats
path: root/org.eclipse.jgit.test
diff options
context:
space:
mode:
authorAndrey Loskutov <loskutov@gmx.de>2014-09-29 16:28:06 +0200
committerAndrey Loskutov <loskutov@gmx.de>2014-10-23 12:31:49 +0200
commit4ea8c655d62e02544c06b4a8ea61929a84fb1c79 (patch)
tree4c1c4d3a10b04dd4a88de6fe5b8062a16918650c /org.eclipse.jgit.test
parent13ffda0666cec94183529307eecbbda3bcf12fb1 (diff)
downloadjgit-4ea8c655d62e02544c06b4a8ea61929a84fb1c79.tar.gz
jgit-4ea8c655d62e02544c06b4a8ea61929a84fb1c79.zip
Initialize 'pathLen' field also for empty directories
Bug: 445363 Change-Id: Ia8428af84fb61ba0d572374a19e8e8c55b138a63 Signed-off-by: Andrey Loskutov <loskutov@gmx.de>
Diffstat (limited to 'org.eclipse.jgit.test')
-rw-r--r--org.eclipse.jgit.test/tst/org/eclipse/jgit/treewalk/FileTreeIteratorTest.java37
1 files changed, 37 insertions, 0 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 51110b1d80..ab4579009b 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
@@ -145,6 +145,43 @@ public class FileTreeIteratorTest extends RepositoryTestCase {
}
@Test
+ public void testEmptyIteratorOnEmptyDirectory() throws Exception {
+ String nonExistingFileName = "not-existing-file";
+ final File r = new File(trash, nonExistingFileName);
+ assertFalse(r.exists());
+ FileUtils.mkdir(r);
+
+ final FileTreeIterator parent = new FileTreeIterator(db);
+
+ while (!parent.getEntryPathString().equals(nonExistingFileName))
+ parent.next(1);
+
+ final FileTreeIterator childIter = new FileTreeIterator(parent, r,
+ db.getFS());
+ assertTrue(childIter.first());
+ assertTrue(childIter.eof());
+
+ String parentPath = parent.getEntryPathString();
+ assertEquals(nonExistingFileName, parentPath);
+
+ // must be "not-existing-file/", but getEntryPathString() was broken by
+ // 445363 too
+ String childPath = childIter.getEntryPathString();
+
+ // in bug 445363 the iterator wrote garbage to the parent "path" field
+ EmptyTreeIterator e = childIter.createEmptyTreeIterator();
+ assertNotNull(e);
+
+ // check if parent path is not overridden by empty iterator (bug 445363)
+ // due bug 445363 this was "/ot-existing-file" instead of
+ // "not-existing-file"
+ assertEquals(parentPath, parent.getEntryPathString());
+ assertEquals(parentPath + "/", childPath);
+ assertEquals(parentPath + "/", childIter.getEntryPathString());
+ assertEquals(childPath + "/", e.getEntryPathString());
+ }
+
+ @Test
public void testSimpleIterate() throws Exception {
final FileTreeIterator top = new FileTreeIterator(trash, db.getFS(),
db.getConfig().get(WorkingTreeOptions.KEY));