diff options
author | Shawn O. Pearce <spearce@spearce.org> | 2010-12-07 16:49:51 -0800 |
---|---|---|
committer | Shawn O. Pearce <spearce@spearce.org> | 2010-12-07 16:49:51 -0800 |
commit | a02be9725c9f83f0a0280a9a1f00e8d484825885 (patch) | |
tree | f816874ef8ce86655e21912952e252e632184f92 /org.eclipse.jgit.test/tst | |
parent | 45731756a56361a51e839e26d3b0bed1c06ee37a (diff) | |
download | jgit-a02be9725c9f83f0a0280a9a1f00e8d484825885.tar.gz jgit-a02be9725c9f83f0a0280a9a1f00e8d484825885.zip |
Remove empty iterator from TreeWalk
Its confusing that a new TreeWalk() needs to have reset() invoked
on it before addTree(). This is a historical accident caused by
how TreeWalk was abused within ObjectWalk.
Drop the initial empty tree from the TreeWalk and thus remove a
number of pointless reset() operations from unit tests and some of
the internal JGit code.
Existing application code which is still calling reset() will simply
be incurring a few unnecessary field assignments, but they should
consider cleaning up their code in the future.
Change-Id: I434e94ffa43491019e7dff52ca420a4d2245f48b
Signed-off-by: Shawn O. Pearce <spearce@spearce.org>
Diffstat (limited to 'org.eclipse.jgit.test/tst')
10 files changed, 5 insertions, 19 deletions
diff --git a/org.eclipse.jgit.test/tst/org/eclipse/jgit/dircache/DirCacheBuilderIteratorTest.java b/org.eclipse.jgit.test/tst/org/eclipse/jgit/dircache/DirCacheBuilderIteratorTest.java index a09f8e86c4..10dcd2af86 100644 --- a/org.eclipse.jgit.test/tst/org/eclipse/jgit/dircache/DirCacheBuilderIteratorTest.java +++ b/org.eclipse.jgit.test/tst/org/eclipse/jgit/dircache/DirCacheBuilderIteratorTest.java @@ -71,7 +71,6 @@ public class DirCacheBuilderIteratorTest extends RepositoryTestCase { final int expIdx = 2; final DirCacheBuilder b = dc.builder(); final TreeWalk tw = new TreeWalk(db); - tw.reset(); tw.addTree(new DirCacheBuildIterator(b)); tw.setRecursive(true); tw.setFilter(PathFilterGroup.createFromStrings(Collections diff --git a/org.eclipse.jgit.test/tst/org/eclipse/jgit/dircache/DirCacheCGitCompatabilityTest.java b/org.eclipse.jgit.test/tst/org/eclipse/jgit/dircache/DirCacheCGitCompatabilityTest.java index a7e2bc823b..00b94b38cf 100644 --- a/org.eclipse.jgit.test/tst/org/eclipse/jgit/dircache/DirCacheCGitCompatabilityTest.java +++ b/org.eclipse.jgit.test/tst/org/eclipse/jgit/dircache/DirCacheCGitCompatabilityTest.java @@ -90,7 +90,6 @@ public class DirCacheCGitCompatabilityTest extends LocalDiskRepositoryTestCase { { final Iterator<CGitIndexRecord> rItr = ls.values().iterator(); final TreeWalk tw = new TreeWalk(db); - tw.reset(); tw.setRecursive(true); tw.addTree(new DirCacheIterator(dc)); while (rItr.hasNext()) { diff --git a/org.eclipse.jgit.test/tst/org/eclipse/jgit/dircache/DirCacheIteratorTest.java b/org.eclipse.jgit.test/tst/org/eclipse/jgit/dircache/DirCacheIteratorTest.java index 24e3c34ddf..9390e29819 100644 --- a/org.eclipse.jgit.test/tst/org/eclipse/jgit/dircache/DirCacheIteratorTest.java +++ b/org.eclipse.jgit.test/tst/org/eclipse/jgit/dircache/DirCacheIteratorTest.java @@ -64,7 +64,6 @@ public class DirCacheIteratorTest extends RepositoryTestCase { assertEquals(0, dc.getEntryCount()); final TreeWalk tw = new TreeWalk(db); - tw.reset(); tw.addTree(new DirCacheIterator(dc)); assertFalse(tw.next()); } @@ -112,7 +111,6 @@ public class DirCacheIteratorTest extends RepositoryTestCase { final DirCacheIterator i = new DirCacheIterator(dc); final TreeWalk tw = new TreeWalk(db); - tw.reset(); tw.addTree(i); int pathIdx = 0; while (tw.next()) { @@ -149,7 +147,6 @@ public class DirCacheIteratorTest extends RepositoryTestCase { final DirCacheIterator i = new DirCacheIterator(dc); final TreeWalk tw = new TreeWalk(db); - tw.reset(); tw.addTree(i); tw.setRecursive(false); int pathIdx = 0; @@ -189,7 +186,6 @@ public class DirCacheIteratorTest extends RepositoryTestCase { final DirCacheIterator i = new DirCacheIterator(dc); final TreeWalk tw = new TreeWalk(db); - tw.reset(); tw.addTree(i); tw.setRecursive(true); int pathIdx = 0; @@ -223,7 +219,6 @@ public class DirCacheIteratorTest extends RepositoryTestCase { b.finish(); final TreeWalk tw = new TreeWalk(db); - tw.reset(); tw.addTree(new DirCacheIterator(dc)); tw.setRecursive(true); int pathIdx = 0; diff --git a/org.eclipse.jgit.test/tst/org/eclipse/jgit/ignore/IgnoreNodeTest.java b/org.eclipse.jgit.test/tst/org/eclipse/jgit/ignore/IgnoreNodeTest.java index f5b6bfb640..867e0603d9 100644 --- a/org.eclipse.jgit.test/tst/org/eclipse/jgit/ignore/IgnoreNodeTest.java +++ b/org.eclipse.jgit.test/tst/org/eclipse/jgit/ignore/IgnoreNodeTest.java @@ -158,7 +158,6 @@ public class IgnoreNodeTest extends RepositoryTestCase { private void beginWalk() throws CorruptObjectException { walk = new TreeWalk(db); - walk.reset(); walk.addTree(new FileTreeIterator(db)); } diff --git a/org.eclipse.jgit.test/tst/org/eclipse/jgit/lib/RacyGitTests.java b/org.eclipse.jgit.test/tst/org/eclipse/jgit/lib/RacyGitTests.java index 5e04f32f82..bf86ef4585 100644 --- a/org.eclipse.jgit.test/tst/org/eclipse/jgit/lib/RacyGitTests.java +++ b/org.eclipse.jgit.test/tst/org/eclipse/jgit/lib/RacyGitTests.java @@ -77,7 +77,6 @@ public class RacyGitTests extends RepositoryTestCase { FileTreeIteratorWithTimeControl fileIt = new FileTreeIteratorWithTimeControl( db, modTimes); NameConflictTreeWalk tw = new NameConflictTreeWalk(db); - tw.reset(); tw.addTree(fileIt); tw.setRecursive(true); FileTreeIterator t; diff --git a/org.eclipse.jgit.test/tst/org/eclipse/jgit/lib/ReadTreeTest.java b/org.eclipse.jgit.test/tst/org/eclipse/jgit/lib/ReadTreeTest.java index b4732e2dc1..2bf81e16f1 100644 --- a/org.eclipse.jgit.test/tst/org/eclipse/jgit/lib/ReadTreeTest.java +++ b/org.eclipse.jgit.test/tst/org/eclipse/jgit/lib/ReadTreeTest.java @@ -685,7 +685,6 @@ public abstract class ReadTreeTest extends RepositoryTestCase { public void assertWorkDir(HashMap<String, String> i) throws CorruptObjectException, IOException { TreeWalk walk = new TreeWalk(db); - walk.reset(); walk.setRecursive(true); walk.addTree(new FileTreeIterator(db)); String expectedValue; diff --git a/org.eclipse.jgit.test/tst/org/eclipse/jgit/treewalk/NameConflictTreeWalkTest.java b/org.eclipse.jgit.test/tst/org/eclipse/jgit/treewalk/NameConflictTreeWalkTest.java index 7e3dea6714..12ed780b8f 100644 --- a/org.eclipse.jgit.test/tst/org/eclipse/jgit/treewalk/NameConflictTreeWalkTest.java +++ b/org.eclipse.jgit.test/tst/org/eclipse/jgit/treewalk/NameConflictTreeWalkTest.java @@ -82,7 +82,6 @@ public class NameConflictTreeWalkTest extends RepositoryTestCase { } final TreeWalk tw = new TreeWalk(db); - tw.reset(); tw.addTree(new DirCacheIterator(tree0)); tw.addTree(new DirCacheIterator(tree1)); @@ -113,7 +112,6 @@ public class NameConflictTreeWalkTest extends RepositoryTestCase { } final NameConflictTreeWalk tw = new NameConflictTreeWalk(db); - tw.reset(); tw.addTree(new DirCacheIterator(tree0)); tw.addTree(new DirCacheIterator(tree1)); @@ -149,7 +147,6 @@ public class NameConflictTreeWalkTest extends RepositoryTestCase { } final NameConflictTreeWalk tw = new NameConflictTreeWalk(db); - tw.reset(); tw.addTree(new DirCacheIterator(tree0)); tw.addTree(new DirCacheIterator(tree1)); @@ -185,7 +182,6 @@ public class NameConflictTreeWalkTest extends RepositoryTestCase { } final NameConflictTreeWalk tw = new NameConflictTreeWalk(db); - tw.reset(); tw.addTree(new DirCacheIterator(tree0)); tw.addTree(new DirCacheIterator(tree1)); @@ -222,7 +218,6 @@ public class NameConflictTreeWalkTest extends RepositoryTestCase { } final NameConflictTreeWalk tw = new NameConflictTreeWalk(db); - tw.reset(); tw.addTree(new DirCacheIterator(tree0)); tw.addTree(new DirCacheIterator(tree1)); diff --git a/org.eclipse.jgit.test/tst/org/eclipse/jgit/treewalk/PostOrderTreeWalkTest.java b/org.eclipse.jgit.test/tst/org/eclipse/jgit/treewalk/PostOrderTreeWalkTest.java index 8f813a806b..9152c60fed 100644 --- a/org.eclipse.jgit.test/tst/org/eclipse/jgit/treewalk/PostOrderTreeWalkTest.java +++ b/org.eclipse.jgit.test/tst/org/eclipse/jgit/treewalk/PostOrderTreeWalkTest.java @@ -98,7 +98,6 @@ public class PostOrderTreeWalkTest extends RepositoryTestCase { } final TreeWalk tw = new TreeWalk(db); - tw.reset(); tw.setPostOrderTraversal(false); tw.addTree(new DirCacheIterator(tree)); @@ -127,7 +126,6 @@ public class PostOrderTreeWalkTest extends RepositoryTestCase { } final TreeWalk tw = new TreeWalk(db); - tw.reset(); tw.setPostOrderTraversal(true); tw.addTree(new DirCacheIterator(tree)); @@ -162,7 +160,6 @@ public class PostOrderTreeWalkTest extends RepositoryTestCase { } final TreeWalk tw = new TreeWalk(db); - tw.reset(); tw.setPostOrderTraversal(true); tw.addTree(new DirCacheIterator(tree)); diff --git a/org.eclipse.jgit.test/tst/org/eclipse/jgit/treewalk/TreeWalkBasicDiffTest.java b/org.eclipse.jgit.test/tst/org/eclipse/jgit/treewalk/TreeWalkBasicDiffTest.java index e0957401c5..7c882719f7 100644 --- a/org.eclipse.jgit.test/tst/org/eclipse/jgit/treewalk/TreeWalkBasicDiffTest.java +++ b/org.eclipse.jgit.test/tst/org/eclipse/jgit/treewalk/TreeWalkBasicDiffTest.java @@ -105,7 +105,7 @@ public class TreeWalkBasicDiffTest extends RepositoryTestCase { inserter.release(); final TreeWalk tw = new TreeWalk(db); - tw.reset(new ObjectId[] { oldTree, newTree }); + tw.reset(oldTree, newTree); tw.setRecursive(true); tw.setFilter(TreeFilter.ANY_DIFF); diff --git a/org.eclipse.jgit.test/tst/org/eclipse/jgit/treewalk/filter/TreeFilterTest.java b/org.eclipse.jgit.test/tst/org/eclipse/jgit/treewalk/filter/TreeFilterTest.java index 12326eade2..4ac82ecad4 100644 --- a/org.eclipse.jgit.test/tst/org/eclipse/jgit/treewalk/filter/TreeFilterTest.java +++ b/org.eclipse.jgit.test/tst/org/eclipse/jgit/treewalk/filter/TreeFilterTest.java @@ -44,11 +44,13 @@ package org.eclipse.jgit.treewalk.filter; import org.eclipse.jgit.lib.RepositoryTestCase; +import org.eclipse.jgit.treewalk.EmptyTreeIterator; import org.eclipse.jgit.treewalk.TreeWalk; public class TreeFilterTest extends RepositoryTestCase { public void testALL_IncludesAnything() throws Exception { final TreeWalk tw = new TreeWalk(db); + tw.addTree(new EmptyTreeIterator()); assertTrue(TreeFilter.ALL.include(tw)); } @@ -62,11 +64,13 @@ public class TreeFilterTest extends RepositoryTestCase { public void testNotALL_IncludesNothing() throws Exception { final TreeWalk tw = new TreeWalk(db); + tw.addTree(new EmptyTreeIterator()); assertFalse(TreeFilter.ALL.negate().include(tw)); } public void testANY_DIFF_IncludesSingleTreeCase() throws Exception { final TreeWalk tw = new TreeWalk(db); + tw.addTree(new EmptyTreeIterator()); assertTrue(TreeFilter.ANY_DIFF.include(tw)); } |