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>
This commit is contained in:
parent
45731756a5
commit
a02be9725c
|
@ -74,7 +74,6 @@ void tree_0(final AbstractTreeIterator c) {
|
||||||
@Override
|
@Override
|
||||||
protected void run() throws Exception {
|
protected void run() throws Exception {
|
||||||
final TreeWalk walk = new TreeWalk(db);
|
final TreeWalk walk = new TreeWalk(db);
|
||||||
walk.reset();
|
|
||||||
walk.setRecursive(recursive);
|
walk.setRecursive(recursive);
|
||||||
for (final AbstractTreeIterator i : trees)
|
for (final AbstractTreeIterator i : trees)
|
||||||
walk.addTree(i);
|
walk.addTree(i);
|
||||||
|
|
|
@ -62,7 +62,6 @@ class LsTree extends TextBuiltin {
|
||||||
@Override
|
@Override
|
||||||
protected void run() throws Exception {
|
protected void run() throws Exception {
|
||||||
final TreeWalk walk = new TreeWalk(db);
|
final TreeWalk walk = new TreeWalk(db);
|
||||||
walk.reset(); // drop the first empty tree, which we do not need here
|
|
||||||
walk.setRecursive(recursive);
|
walk.setRecursive(recursive);
|
||||||
walk.addTree(tree);
|
walk.addTree(tree);
|
||||||
|
|
||||||
|
|
|
@ -59,7 +59,6 @@
|
||||||
import org.eclipse.jgit.diff.RawTextComparator;
|
import org.eclipse.jgit.diff.RawTextComparator;
|
||||||
import org.eclipse.jgit.errors.LargeObjectException;
|
import org.eclipse.jgit.errors.LargeObjectException;
|
||||||
import org.eclipse.jgit.lib.AbbreviatedObjectId;
|
import org.eclipse.jgit.lib.AbbreviatedObjectId;
|
||||||
import org.eclipse.jgit.lib.AnyObjectId;
|
|
||||||
import org.eclipse.jgit.lib.Constants;
|
import org.eclipse.jgit.lib.Constants;
|
||||||
import org.eclipse.jgit.lib.FileMode;
|
import org.eclipse.jgit.lib.FileMode;
|
||||||
import org.eclipse.jgit.lib.MutableObjectId;
|
import org.eclipse.jgit.lib.MutableObjectId;
|
||||||
|
@ -190,7 +189,7 @@ private void run(Repository db) throws Exception {
|
||||||
|
|
||||||
RevCommit p = c.getParent(0);
|
RevCommit p = c.getParent(0);
|
||||||
rw.parseHeaders(p);
|
rw.parseHeaders(p);
|
||||||
tw.reset(new AnyObjectId[] { p.getTree(), c.getTree() });
|
tw.reset(p.getTree(), c.getTree());
|
||||||
while (tw.next()) {
|
while (tw.next()) {
|
||||||
if (!isFile(tw, 0) || !isFile(tw, 1))
|
if (!isFile(tw, 0) || !isFile(tw, 1))
|
||||||
continue;
|
continue;
|
||||||
|
|
|
@ -71,7 +71,6 @@ public void testPathFilterGroup_DoesNotSkipTail() throws Exception {
|
||||||
final int expIdx = 2;
|
final int expIdx = 2;
|
||||||
final DirCacheBuilder b = dc.builder();
|
final DirCacheBuilder b = dc.builder();
|
||||||
final TreeWalk tw = new TreeWalk(db);
|
final TreeWalk tw = new TreeWalk(db);
|
||||||
tw.reset();
|
|
||||||
tw.addTree(new DirCacheBuildIterator(b));
|
tw.addTree(new DirCacheBuildIterator(b));
|
||||||
tw.setRecursive(true);
|
tw.setRecursive(true);
|
||||||
tw.setFilter(PathFilterGroup.createFromStrings(Collections
|
tw.setFilter(PathFilterGroup.createFromStrings(Collections
|
||||||
|
|
|
@ -90,7 +90,6 @@ public void testTreeWalk_LsFiles() throws Exception {
|
||||||
{
|
{
|
||||||
final Iterator<CGitIndexRecord> rItr = ls.values().iterator();
|
final Iterator<CGitIndexRecord> rItr = ls.values().iterator();
|
||||||
final TreeWalk tw = new TreeWalk(db);
|
final TreeWalk tw = new TreeWalk(db);
|
||||||
tw.reset();
|
|
||||||
tw.setRecursive(true);
|
tw.setRecursive(true);
|
||||||
tw.addTree(new DirCacheIterator(dc));
|
tw.addTree(new DirCacheIterator(dc));
|
||||||
while (rItr.hasNext()) {
|
while (rItr.hasNext()) {
|
||||||
|
|
|
@ -64,7 +64,6 @@ public void testEmptyTree_WithTreeWalk() throws Exception {
|
||||||
assertEquals(0, dc.getEntryCount());
|
assertEquals(0, dc.getEntryCount());
|
||||||
|
|
||||||
final TreeWalk tw = new TreeWalk(db);
|
final TreeWalk tw = new TreeWalk(db);
|
||||||
tw.reset();
|
|
||||||
tw.addTree(new DirCacheIterator(dc));
|
tw.addTree(new DirCacheIterator(dc));
|
||||||
assertFalse(tw.next());
|
assertFalse(tw.next());
|
||||||
}
|
}
|
||||||
|
@ -112,7 +111,6 @@ public void testNoSubtree_WithTreeWalk() throws Exception {
|
||||||
|
|
||||||
final DirCacheIterator i = new DirCacheIterator(dc);
|
final DirCacheIterator i = new DirCacheIterator(dc);
|
||||||
final TreeWalk tw = new TreeWalk(db);
|
final TreeWalk tw = new TreeWalk(db);
|
||||||
tw.reset();
|
|
||||||
tw.addTree(i);
|
tw.addTree(i);
|
||||||
int pathIdx = 0;
|
int pathIdx = 0;
|
||||||
while (tw.next()) {
|
while (tw.next()) {
|
||||||
|
@ -149,7 +147,6 @@ public void testSingleSubtree_NoRecursion() throws Exception {
|
||||||
|
|
||||||
final DirCacheIterator i = new DirCacheIterator(dc);
|
final DirCacheIterator i = new DirCacheIterator(dc);
|
||||||
final TreeWalk tw = new TreeWalk(db);
|
final TreeWalk tw = new TreeWalk(db);
|
||||||
tw.reset();
|
|
||||||
tw.addTree(i);
|
tw.addTree(i);
|
||||||
tw.setRecursive(false);
|
tw.setRecursive(false);
|
||||||
int pathIdx = 0;
|
int pathIdx = 0;
|
||||||
|
@ -189,7 +186,6 @@ public void testSingleSubtree_Recursive() throws Exception {
|
||||||
|
|
||||||
final DirCacheIterator i = new DirCacheIterator(dc);
|
final DirCacheIterator i = new DirCacheIterator(dc);
|
||||||
final TreeWalk tw = new TreeWalk(db);
|
final TreeWalk tw = new TreeWalk(db);
|
||||||
tw.reset();
|
|
||||||
tw.addTree(i);
|
tw.addTree(i);
|
||||||
tw.setRecursive(true);
|
tw.setRecursive(true);
|
||||||
int pathIdx = 0;
|
int pathIdx = 0;
|
||||||
|
@ -223,7 +219,6 @@ public void testTwoLevelSubtree_Recursive() throws Exception {
|
||||||
b.finish();
|
b.finish();
|
||||||
|
|
||||||
final TreeWalk tw = new TreeWalk(db);
|
final TreeWalk tw = new TreeWalk(db);
|
||||||
tw.reset();
|
|
||||||
tw.addTree(new DirCacheIterator(dc));
|
tw.addTree(new DirCacheIterator(dc));
|
||||||
tw.setRecursive(true);
|
tw.setRecursive(true);
|
||||||
int pathIdx = 0;
|
int pathIdx = 0;
|
||||||
|
|
|
@ -158,7 +158,6 @@ public void testWithSlashDoesNotMatchInSubDirectory() throws IOException {
|
||||||
|
|
||||||
private void beginWalk() throws CorruptObjectException {
|
private void beginWalk() throws CorruptObjectException {
|
||||||
walk = new TreeWalk(db);
|
walk = new TreeWalk(db);
|
||||||
walk.reset();
|
|
||||||
walk.addTree(new FileTreeIterator(db));
|
walk.addTree(new FileTreeIterator(db));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -77,7 +77,6 @@ public void testIterator() throws IllegalStateException, IOException,
|
||||||
FileTreeIteratorWithTimeControl fileIt = new FileTreeIteratorWithTimeControl(
|
FileTreeIteratorWithTimeControl fileIt = new FileTreeIteratorWithTimeControl(
|
||||||
db, modTimes);
|
db, modTimes);
|
||||||
NameConflictTreeWalk tw = new NameConflictTreeWalk(db);
|
NameConflictTreeWalk tw = new NameConflictTreeWalk(db);
|
||||||
tw.reset();
|
|
||||||
tw.addTree(fileIt);
|
tw.addTree(fileIt);
|
||||||
tw.setRecursive(true);
|
tw.setRecursive(true);
|
||||||
FileTreeIterator t;
|
FileTreeIterator t;
|
||||||
|
|
|
@ -685,7 +685,6 @@ interface Checkout {
|
||||||
public void assertWorkDir(HashMap<String, String> i)
|
public void assertWorkDir(HashMap<String, String> i)
|
||||||
throws CorruptObjectException, IOException {
|
throws CorruptObjectException, IOException {
|
||||||
TreeWalk walk = new TreeWalk(db);
|
TreeWalk walk = new TreeWalk(db);
|
||||||
walk.reset();
|
|
||||||
walk.setRecursive(true);
|
walk.setRecursive(true);
|
||||||
walk.addTree(new FileTreeIterator(db));
|
walk.addTree(new FileTreeIterator(db));
|
||||||
String expectedValue;
|
String expectedValue;
|
||||||
|
|
|
@ -82,7 +82,6 @@ public void testNoDF_NoGap() throws Exception {
|
||||||
}
|
}
|
||||||
|
|
||||||
final TreeWalk tw = new TreeWalk(db);
|
final TreeWalk tw = new TreeWalk(db);
|
||||||
tw.reset();
|
|
||||||
tw.addTree(new DirCacheIterator(tree0));
|
tw.addTree(new DirCacheIterator(tree0));
|
||||||
tw.addTree(new DirCacheIterator(tree1));
|
tw.addTree(new DirCacheIterator(tree1));
|
||||||
|
|
||||||
|
@ -113,7 +112,6 @@ public void testDF_NoGap() throws Exception {
|
||||||
}
|
}
|
||||||
|
|
||||||
final NameConflictTreeWalk tw = new NameConflictTreeWalk(db);
|
final NameConflictTreeWalk tw = new NameConflictTreeWalk(db);
|
||||||
tw.reset();
|
|
||||||
tw.addTree(new DirCacheIterator(tree0));
|
tw.addTree(new DirCacheIterator(tree0));
|
||||||
tw.addTree(new DirCacheIterator(tree1));
|
tw.addTree(new DirCacheIterator(tree1));
|
||||||
|
|
||||||
|
@ -149,7 +147,6 @@ public void testDF_GapByOne() throws Exception {
|
||||||
}
|
}
|
||||||
|
|
||||||
final NameConflictTreeWalk tw = new NameConflictTreeWalk(db);
|
final NameConflictTreeWalk tw = new NameConflictTreeWalk(db);
|
||||||
tw.reset();
|
|
||||||
tw.addTree(new DirCacheIterator(tree0));
|
tw.addTree(new DirCacheIterator(tree0));
|
||||||
tw.addTree(new DirCacheIterator(tree1));
|
tw.addTree(new DirCacheIterator(tree1));
|
||||||
|
|
||||||
|
@ -185,7 +182,6 @@ public void testDF_SkipsSeenSubtree() throws Exception {
|
||||||
}
|
}
|
||||||
|
|
||||||
final NameConflictTreeWalk tw = new NameConflictTreeWalk(db);
|
final NameConflictTreeWalk tw = new NameConflictTreeWalk(db);
|
||||||
tw.reset();
|
|
||||||
tw.addTree(new DirCacheIterator(tree0));
|
tw.addTree(new DirCacheIterator(tree0));
|
||||||
tw.addTree(new DirCacheIterator(tree1));
|
tw.addTree(new DirCacheIterator(tree1));
|
||||||
|
|
||||||
|
@ -222,7 +218,6 @@ public void testDF_DetectConflict() throws Exception {
|
||||||
}
|
}
|
||||||
|
|
||||||
final NameConflictTreeWalk tw = new NameConflictTreeWalk(db);
|
final NameConflictTreeWalk tw = new NameConflictTreeWalk(db);
|
||||||
tw.reset();
|
|
||||||
tw.addTree(new DirCacheIterator(tree0));
|
tw.addTree(new DirCacheIterator(tree0));
|
||||||
tw.addTree(new DirCacheIterator(tree1));
|
tw.addTree(new DirCacheIterator(tree1));
|
||||||
|
|
||||||
|
|
|
@ -98,7 +98,6 @@ public void testNoPostOrder() throws Exception {
|
||||||
}
|
}
|
||||||
|
|
||||||
final TreeWalk tw = new TreeWalk(db);
|
final TreeWalk tw = new TreeWalk(db);
|
||||||
tw.reset();
|
|
||||||
tw.setPostOrderTraversal(false);
|
tw.setPostOrderTraversal(false);
|
||||||
tw.addTree(new DirCacheIterator(tree));
|
tw.addTree(new DirCacheIterator(tree));
|
||||||
|
|
||||||
|
@ -127,7 +126,6 @@ public void testWithPostOrder_EnterSubtree() throws Exception {
|
||||||
}
|
}
|
||||||
|
|
||||||
final TreeWalk tw = new TreeWalk(db);
|
final TreeWalk tw = new TreeWalk(db);
|
||||||
tw.reset();
|
|
||||||
tw.setPostOrderTraversal(true);
|
tw.setPostOrderTraversal(true);
|
||||||
tw.addTree(new DirCacheIterator(tree));
|
tw.addTree(new DirCacheIterator(tree));
|
||||||
|
|
||||||
|
@ -162,7 +160,6 @@ public void testWithPostOrder_NoEnterSubtree() throws Exception {
|
||||||
}
|
}
|
||||||
|
|
||||||
final TreeWalk tw = new TreeWalk(db);
|
final TreeWalk tw = new TreeWalk(db);
|
||||||
tw.reset();
|
|
||||||
tw.setPostOrderTraversal(true);
|
tw.setPostOrderTraversal(true);
|
||||||
tw.addTree(new DirCacheIterator(tree));
|
tw.addTree(new DirCacheIterator(tree));
|
||||||
|
|
||||||
|
|
|
@ -105,7 +105,7 @@ public void testMissingSubtree_DetectFileAdded_FileModified()
|
||||||
inserter.release();
|
inserter.release();
|
||||||
|
|
||||||
final TreeWalk tw = new TreeWalk(db);
|
final TreeWalk tw = new TreeWalk(db);
|
||||||
tw.reset(new ObjectId[] { oldTree, newTree });
|
tw.reset(oldTree, newTree);
|
||||||
tw.setRecursive(true);
|
tw.setRecursive(true);
|
||||||
tw.setFilter(TreeFilter.ANY_DIFF);
|
tw.setFilter(TreeFilter.ANY_DIFF);
|
||||||
|
|
||||||
|
|
|
@ -44,11 +44,13 @@
|
||||||
package org.eclipse.jgit.treewalk.filter;
|
package org.eclipse.jgit.treewalk.filter;
|
||||||
|
|
||||||
import org.eclipse.jgit.lib.RepositoryTestCase;
|
import org.eclipse.jgit.lib.RepositoryTestCase;
|
||||||
|
import org.eclipse.jgit.treewalk.EmptyTreeIterator;
|
||||||
import org.eclipse.jgit.treewalk.TreeWalk;
|
import org.eclipse.jgit.treewalk.TreeWalk;
|
||||||
|
|
||||||
public class TreeFilterTest extends RepositoryTestCase {
|
public class TreeFilterTest extends RepositoryTestCase {
|
||||||
public void testALL_IncludesAnything() throws Exception {
|
public void testALL_IncludesAnything() throws Exception {
|
||||||
final TreeWalk tw = new TreeWalk(db);
|
final TreeWalk tw = new TreeWalk(db);
|
||||||
|
tw.addTree(new EmptyTreeIterator());
|
||||||
assertTrue(TreeFilter.ALL.include(tw));
|
assertTrue(TreeFilter.ALL.include(tw));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -62,11 +64,13 @@ public void testALL_IdentityClone() throws Exception {
|
||||||
|
|
||||||
public void testNotALL_IncludesNothing() throws Exception {
|
public void testNotALL_IncludesNothing() throws Exception {
|
||||||
final TreeWalk tw = new TreeWalk(db);
|
final TreeWalk tw = new TreeWalk(db);
|
||||||
|
tw.addTree(new EmptyTreeIterator());
|
||||||
assertFalse(TreeFilter.ALL.negate().include(tw));
|
assertFalse(TreeFilter.ALL.negate().include(tw));
|
||||||
}
|
}
|
||||||
|
|
||||||
public void testANY_DIFF_IncludesSingleTreeCase() throws Exception {
|
public void testANY_DIFF_IncludesSingleTreeCase() throws Exception {
|
||||||
final TreeWalk tw = new TreeWalk(db);
|
final TreeWalk tw = new TreeWalk(db);
|
||||||
|
tw.addTree(new EmptyTreeIterator());
|
||||||
assertTrue(TreeFilter.ANY_DIFF.include(tw));
|
assertTrue(TreeFilter.ANY_DIFF.include(tw));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -138,7 +138,6 @@ public DirCache call() throws NoFilepatternException {
|
||||||
|
|
||||||
DirCacheBuilder builder = dc.builder();
|
DirCacheBuilder builder = dc.builder();
|
||||||
final TreeWalk tw = new TreeWalk(repo);
|
final TreeWalk tw = new TreeWalk(repo);
|
||||||
tw.reset();
|
|
||||||
tw.addTree(new DirCacheBuildIterator(builder));
|
tw.addTree(new DirCacheBuildIterator(builder));
|
||||||
if (workingTreeIterator == null)
|
if (workingTreeIterator == null)
|
||||||
workingTreeIterator = new FileTreeIterator(repo);
|
workingTreeIterator = new FileTreeIterator(repo);
|
||||||
|
|
|
@ -431,7 +431,6 @@ public List<DiffEntry> scan(AbstractTreeIterator a, AbstractTreeIterator b)
|
||||||
assertHaveRepository();
|
assertHaveRepository();
|
||||||
|
|
||||||
TreeWalk walk = new TreeWalk(reader);
|
TreeWalk walk = new TreeWalk(reader);
|
||||||
walk.reset();
|
|
||||||
walk.addTree(a);
|
walk.addTree(a);
|
||||||
walk.addTree(b);
|
walk.addTree(b);
|
||||||
walk.setRecursive(true);
|
walk.setRecursive(true);
|
||||||
|
|
|
@ -165,7 +165,6 @@ public void keep(final int pos, int cnt) {
|
||||||
public void addTree(final byte[] pathPrefix, final int stage,
|
public void addTree(final byte[] pathPrefix, final int stage,
|
||||||
final ObjectReader reader, final AnyObjectId tree) throws IOException {
|
final ObjectReader reader, final AnyObjectId tree) throws IOException {
|
||||||
final TreeWalk tw = new TreeWalk(reader);
|
final TreeWalk tw = new TreeWalk(reader);
|
||||||
tw.reset();
|
|
||||||
tw.addTree(new CanonicalTreeParser(pathPrefix, reader, tree
|
tw.addTree(new CanonicalTreeParser(pathPrefix, reader, tree
|
||||||
.toObjectId()));
|
.toObjectId()));
|
||||||
tw.setRecursive(true);
|
tw.setRecursive(true);
|
||||||
|
|
|
@ -243,7 +243,6 @@ public void preScanTwoTrees() throws CorruptObjectException, IOException {
|
||||||
walk = new NameConflictTreeWalk(repo);
|
walk = new NameConflictTreeWalk(repo);
|
||||||
builder = dc.builder();
|
builder = dc.builder();
|
||||||
|
|
||||||
walk.reset();
|
|
||||||
addTree(walk, headCommitTree);
|
addTree(walk, headCommitTree);
|
||||||
addTree(walk, mergeCommitTree);
|
addTree(walk, mergeCommitTree);
|
||||||
walk.addTree(new DirCacheBuildIterator(builder));
|
walk.addTree(new DirCacheBuildIterator(builder));
|
||||||
|
@ -285,7 +284,6 @@ public void prescanOneTree()
|
||||||
builder = dc.builder();
|
builder = dc.builder();
|
||||||
|
|
||||||
walk = new NameConflictTreeWalk(repo);
|
walk = new NameConflictTreeWalk(repo);
|
||||||
walk.reset();
|
|
||||||
walk.addTree(mergeCommitTree);
|
walk.addTree(mergeCommitTree);
|
||||||
walk.addTree(new DirCacheBuildIterator(builder));
|
walk.addTree(new DirCacheBuildIterator(builder));
|
||||||
walk.addTree(workingTree);
|
walk.addTree(workingTree);
|
||||||
|
@ -795,7 +793,6 @@ private void cleanUpConflicts() throws CheckoutConflictException {
|
||||||
|
|
||||||
private boolean isModified(String path) throws CorruptObjectException, IOException {
|
private boolean isModified(String path) throws CorruptObjectException, IOException {
|
||||||
NameConflictTreeWalk tw = new NameConflictTreeWalk(repo);
|
NameConflictTreeWalk tw = new NameConflictTreeWalk(repo);
|
||||||
tw.reset();
|
|
||||||
tw.addTree(new DirCacheIterator(dc));
|
tw.addTree(new DirCacheIterator(dc));
|
||||||
tw.addTree(new FileTreeIterator(repo.getWorkTree(), repo.getFS(),
|
tw.addTree(new FileTreeIterator(repo.getWorkTree(), repo.getFS(),
|
||||||
WorkingTreeOptions.createDefaultInstance()));
|
WorkingTreeOptions.createDefaultInstance()));
|
||||||
|
|
|
@ -169,7 +169,6 @@ public boolean diff() throws IOException {
|
||||||
boolean changesExist = false;
|
boolean changesExist = false;
|
||||||
DirCache dirCache = repository.readDirCache();
|
DirCache dirCache = repository.readDirCache();
|
||||||
TreeWalk treeWalk = new TreeWalk(repository);
|
TreeWalk treeWalk = new TreeWalk(repository);
|
||||||
treeWalk.reset();
|
|
||||||
treeWalk.setRecursive(true);
|
treeWalk.setRecursive(true);
|
||||||
// add the trees (tree, dirchache, workdir)
|
// add the trees (tree, dirchache, workdir)
|
||||||
if (tree != null)
|
if (tree != null)
|
||||||
|
|
|
@ -59,10 +59,10 @@
|
||||||
|
|
||||||
import org.eclipse.jgit.JGitText;
|
import org.eclipse.jgit.JGitText;
|
||||||
import org.eclipse.jgit.diff.DiffAlgorithm;
|
import org.eclipse.jgit.diff.DiffAlgorithm;
|
||||||
import org.eclipse.jgit.diff.DiffAlgorithm.SupportedAlgorithm;
|
|
||||||
import org.eclipse.jgit.diff.RawText;
|
import org.eclipse.jgit.diff.RawText;
|
||||||
import org.eclipse.jgit.diff.RawTextComparator;
|
import org.eclipse.jgit.diff.RawTextComparator;
|
||||||
import org.eclipse.jgit.diff.Sequence;
|
import org.eclipse.jgit.diff.Sequence;
|
||||||
|
import org.eclipse.jgit.diff.DiffAlgorithm.SupportedAlgorithm;
|
||||||
import org.eclipse.jgit.dircache.DirCache;
|
import org.eclipse.jgit.dircache.DirCache;
|
||||||
import org.eclipse.jgit.dircache.DirCacheBuildIterator;
|
import org.eclipse.jgit.dircache.DirCacheBuildIterator;
|
||||||
import org.eclipse.jgit.dircache.DirCacheBuilder;
|
import org.eclipse.jgit.dircache.DirCacheBuilder;
|
||||||
|
@ -183,7 +183,6 @@ protected boolean mergeImpl() throws IOException {
|
||||||
DirCacheBuildIterator buildIt = new DirCacheBuildIterator(builder);
|
DirCacheBuildIterator buildIt = new DirCacheBuildIterator(builder);
|
||||||
|
|
||||||
tw = new NameConflictTreeWalk(db);
|
tw = new NameConflictTreeWalk(db);
|
||||||
tw.reset();
|
|
||||||
tw.addTree(mergeBase());
|
tw.addTree(mergeBase());
|
||||||
tw.addTree(sourceTrees[0]);
|
tw.addTree(sourceTrees[0]);
|
||||||
tw.addTree(sourceTrees[1]);
|
tw.addTree(sourceTrees[1]);
|
||||||
|
|
|
@ -112,7 +112,6 @@ private static class InCoreMerger extends ThreeWayMerger {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected boolean mergeImpl() throws IOException {
|
protected boolean mergeImpl() throws IOException {
|
||||||
tw.reset();
|
|
||||||
tw.addTree(mergeBase());
|
tw.addTree(mergeBase());
|
||||||
tw.addTree(sourceTrees[0]);
|
tw.addTree(sourceTrees[0]);
|
||||||
tw.addTree(sourceTrees[1]);
|
tw.addTree(sourceTrees[1]);
|
||||||
|
|
|
@ -84,6 +84,8 @@
|
||||||
* permitted, even from concurrent threads.
|
* permitted, even from concurrent threads.
|
||||||
*/
|
*/
|
||||||
public class TreeWalk {
|
public class TreeWalk {
|
||||||
|
private static final AbstractTreeIterator[] NO_TREES = {};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Open a tree walk and filter to exactly one path.
|
* Open a tree walk and filter to exactly one path.
|
||||||
* <p>
|
* <p>
|
||||||
|
@ -226,7 +228,7 @@ public TreeWalk(final Repository repo) {
|
||||||
public TreeWalk(final ObjectReader or) {
|
public TreeWalk(final ObjectReader or) {
|
||||||
reader = or;
|
reader = or;
|
||||||
filter = TreeFilter.ALL;
|
filter = TreeFilter.ALL;
|
||||||
trees = new AbstractTreeIterator[] { new EmptyTreeIterator() };
|
trees = NO_TREES;
|
||||||
}
|
}
|
||||||
|
|
||||||
/** @return the reader this walker is using to load objects. */
|
/** @return the reader this walker is using to load objects. */
|
||||||
|
@ -337,7 +339,7 @@ public void setPostOrderTraversal(final boolean b) {
|
||||||
|
|
||||||
/** Reset this walker so new tree iterators can be added to it. */
|
/** Reset this walker so new tree iterators can be added to it. */
|
||||||
public void reset() {
|
public void reset() {
|
||||||
trees = new AbstractTreeIterator[0];
|
trees = NO_TREES;
|
||||||
advance = false;
|
advance = false;
|
||||||
depth = 0;
|
depth = 0;
|
||||||
}
|
}
|
||||||
|
@ -400,7 +402,7 @@ public void reset(final AnyObjectId id) throws MissingObjectException,
|
||||||
* @throws IOException
|
* @throws IOException
|
||||||
* a loose object or pack file could not be read.
|
* a loose object or pack file could not be read.
|
||||||
*/
|
*/
|
||||||
public void reset(final AnyObjectId[] ids) throws MissingObjectException,
|
public void reset(final AnyObjectId... ids) throws MissingObjectException,
|
||||||
IncorrectObjectTypeException, CorruptObjectException, IOException {
|
IncorrectObjectTypeException, CorruptObjectException, IOException {
|
||||||
final int oldLen = trees.length;
|
final int oldLen = trees.length;
|
||||||
final int newLen = ids.length;
|
final int newLen = ids.length;
|
||||||
|
|
Loading…
Reference in New Issue