|
|
|
@ -76,10 +76,11 @@ public class DirCacheIteratorTest extends RepositoryTestCase {
|
|
|
|
|
final DirCache dc = DirCache.newInCore(); |
|
|
|
|
assertEquals(0, dc.getEntryCount()); |
|
|
|
|
|
|
|
|
|
final TreeWalk tw = new TreeWalk(db); |
|
|
|
|
try (final TreeWalk tw = new TreeWalk(db)) { |
|
|
|
|
tw.addTree(new DirCacheIterator(dc)); |
|
|
|
|
assertFalse(tw.next()); |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
@Test |
|
|
|
|
public void testNoSubtree_NoTreeWalk() throws Exception { |
|
|
|
@ -125,7 +126,7 @@ public class DirCacheIteratorTest extends RepositoryTestCase {
|
|
|
|
|
b.finish(); |
|
|
|
|
|
|
|
|
|
final DirCacheIterator i = new DirCacheIterator(dc); |
|
|
|
|
final TreeWalk tw = new TreeWalk(db); |
|
|
|
|
try (final TreeWalk tw = new TreeWalk(db)) { |
|
|
|
|
tw.addTree(i); |
|
|
|
|
int pathIdx = 0; |
|
|
|
|
while (tw.next()) { |
|
|
|
@ -139,6 +140,7 @@ public class DirCacheIteratorTest extends RepositoryTestCase {
|
|
|
|
|
} |
|
|
|
|
assertEquals(paths.length, pathIdx); |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
@Test |
|
|
|
|
public void testSingleSubtree_NoRecursion() throws Exception { |
|
|
|
@ -162,7 +164,7 @@ public class DirCacheIteratorTest extends RepositoryTestCase {
|
|
|
|
|
final int expPos[] = { 0, -1, 4 }; |
|
|
|
|
|
|
|
|
|
final DirCacheIterator i = new DirCacheIterator(dc); |
|
|
|
|
final TreeWalk tw = new TreeWalk(db); |
|
|
|
|
try (final TreeWalk tw = new TreeWalk(db)) { |
|
|
|
|
tw.addTree(i); |
|
|
|
|
tw.setRecursive(false); |
|
|
|
|
int pathIdx = 0; |
|
|
|
@ -183,6 +185,7 @@ public class DirCacheIteratorTest extends RepositoryTestCase {
|
|
|
|
|
} |
|
|
|
|
assertEquals(expPaths.length, pathIdx); |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
@Test |
|
|
|
|
public void testSingleSubtree_Recursive() throws Exception { |
|
|
|
@ -202,7 +205,7 @@ public class DirCacheIteratorTest extends RepositoryTestCase {
|
|
|
|
|
b.finish(); |
|
|
|
|
|
|
|
|
|
final DirCacheIterator i = new DirCacheIterator(dc); |
|
|
|
|
final TreeWalk tw = new TreeWalk(db); |
|
|
|
|
try (final TreeWalk tw = new TreeWalk(db)) { |
|
|
|
|
tw.addTree(i); |
|
|
|
|
tw.setRecursive(true); |
|
|
|
|
int pathIdx = 0; |
|
|
|
@ -218,6 +221,7 @@ public class DirCacheIteratorTest extends RepositoryTestCase {
|
|
|
|
|
} |
|
|
|
|
assertEquals(paths.length, pathIdx); |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
@Test |
|
|
|
|
public void testTwoLevelSubtree_Recursive() throws Exception { |
|
|
|
@ -236,7 +240,7 @@ public class DirCacheIteratorTest extends RepositoryTestCase {
|
|
|
|
|
b.add(ents[i]); |
|
|
|
|
b.finish(); |
|
|
|
|
|
|
|
|
|
final TreeWalk tw = new TreeWalk(db); |
|
|
|
|
try (final TreeWalk tw = new TreeWalk(db)) { |
|
|
|
|
tw.addTree(new DirCacheIterator(dc)); |
|
|
|
|
tw.setRecursive(true); |
|
|
|
|
int pathIdx = 0; |
|
|
|
@ -252,6 +256,7 @@ public class DirCacheIteratorTest extends RepositoryTestCase {
|
|
|
|
|
} |
|
|
|
|
assertEquals(paths.length, pathIdx); |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
@Test |
|
|
|
|
public void testReset() throws Exception { |
|
|
|
@ -397,7 +402,7 @@ public class DirCacheIteratorTest extends RepositoryTestCase {
|
|
|
|
|
b.add(ents[i]); |
|
|
|
|
b.finish(); |
|
|
|
|
|
|
|
|
|
final TreeWalk tw = new TreeWalk(db); |
|
|
|
|
try (final TreeWalk tw = new TreeWalk(db)) { |
|
|
|
|
for (int victimIdx = 0; victimIdx < paths.length; victimIdx++) { |
|
|
|
|
tw.reset(); |
|
|
|
|
tw.addTree(new DirCacheIterator(dc)); |
|
|
|
@ -415,6 +420,7 @@ public class DirCacheIteratorTest extends RepositoryTestCase {
|
|
|
|
|
assertFalse(tw.next()); |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
@Test |
|
|
|
|
public void testRemovedSubtree() throws Exception { |
|
|
|
@ -424,7 +430,7 @@ public class DirCacheIteratorTest extends RepositoryTestCase {
|
|
|
|
|
final DirCache dc = DirCache.read(path, FS.DETECTED); |
|
|
|
|
assertEquals(2, dc.getEntryCount()); |
|
|
|
|
|
|
|
|
|
final TreeWalk tw = new TreeWalk(db); |
|
|
|
|
try (final TreeWalk tw = new TreeWalk(db)) { |
|
|
|
|
tw.setRecursive(true); |
|
|
|
|
tw.addTree(new DirCacheIterator(dc)); |
|
|
|
|
|
|
|
|
@ -438,4 +444,5 @@ public class DirCacheIteratorTest extends RepositoryTestCase {
|
|
|
|
|
|
|
|
|
|
assertFalse(tw.next()); |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|