summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorShawn O. Pearce <spearce@spearce.org>2011-01-30 14:43:49 -0800
committerShawn O. Pearce <spearce@spearce.org>2011-01-31 12:31:52 -0800
commitc2ab3421a25d8f218951e6c3186037cb0b4e3a34 (patch)
treedc4f666a2b57fab61951be85531ee7e1a3f68f2e
parent9ffcf2a8b3cb49c445fabd011b26a36e622a033c (diff)
downloadjgit-c2ab3421a25d8f218951e6c3186037cb0b4e3a34.tar.gz
jgit-c2ab3421a25d8f218951e6c3186037cb0b4e3a34.zip
ObjectWalk: Fix reset for non-commit objects
Non-commits are added to a pending queue, but duplicates are removed by checking a flag. During a reset that flag must be stripped off the old roots, otherwise the caller cannot reuse the old roots after the reset. RevWalk already does this correctly for commits, but ObjectWalk failed to handle the non-commit case itself. Change-Id: I99e1832bf204eac5a424fdb04f327792e8cded4a Signed-off-by: Shawn O. Pearce <spearce@spearce.org>
-rw-r--r--org.eclipse.jgit/src/org/eclipse/jgit/revwalk/ObjectWalk.java11
1 files changed, 11 insertions, 0 deletions
diff --git a/org.eclipse.jgit/src/org/eclipse/jgit/revwalk/ObjectWalk.java b/org.eclipse.jgit/src/org/eclipse/jgit/revwalk/ObjectWalk.java
index 3df5a468f6..aeba3160dc 100644
--- a/org.eclipse.jgit/src/org/eclipse/jgit/revwalk/ObjectWalk.java
+++ b/org.eclipse.jgit/src/org/eclipse/jgit/revwalk/ObjectWalk.java
@@ -45,6 +45,8 @@ package org.eclipse.jgit.revwalk;
import java.io.IOException;
import java.text.MessageFormat;
+import java.util.ArrayList;
+import java.util.List;
import org.eclipse.jgit.JGitText;
import org.eclipse.jgit.errors.CorruptObjectException;
@@ -85,6 +87,8 @@ public class ObjectWalk extends RevWalk {
private CanonicalTreeParser treeWalk;
+ private List<RevObject> rootObjects;
+
private BlockObjQueue pendingObjects;
private RevTree currentTree;
@@ -115,6 +119,7 @@ public class ObjectWalk extends RevWalk {
*/
public ObjectWalk(ObjectReader or) {
super(or);
+ rootObjects = new ArrayList<RevObject>();
pendingObjects = new BlockObjQueue();
treeWalk = new CanonicalTreeParser();
}
@@ -425,6 +430,11 @@ public class ObjectWalk extends RevWalk {
@Override
protected void reset(final int retainFlags) {
super.reset(retainFlags);
+
+ for (RevObject obj : rootObjects)
+ obj.flags &= ~IN_PENDING;
+
+ rootObjects = new ArrayList<RevObject>();
pendingObjects = new BlockObjQueue();
treeWalk = new CanonicalTreeParser();
currentTree = null;
@@ -436,6 +446,7 @@ public class ObjectWalk extends RevWalk {
private void addObject(final RevObject o) {
if ((o.flags & IN_PENDING) == 0) {
o.flags |= IN_PENDING;
+ rootObjects.add(o);
pendingObjects.add(o);
}
}