From a02be9725c9f83f0a0280a9a1f00e8d484825885 Mon Sep 17 00:00:00 2001 From: "Shawn O. Pearce" Date: Tue, 7 Dec 2010 16:49:51 -0800 Subject: 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 --- .../tst/org/eclipse/jgit/dircache/DirCacheBuilderIteratorTest.java | 1 - .../tst/org/eclipse/jgit/dircache/DirCacheCGitCompatabilityTest.java | 1 - .../tst/org/eclipse/jgit/dircache/DirCacheIteratorTest.java | 5 ----- 3 files changed, 7 deletions(-) (limited to 'org.eclipse.jgit.test/tst/org/eclipse/jgit/dircache') 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 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; -- cgit v1.2.3