From 733a0d14823ad3470ca03f346b566b5e656e54ed Mon Sep 17 00:00:00 2001 From: "Shawn O. Pearce" Date: Tue, 16 Sep 2008 12:34:37 -0700 Subject: [PATCH] More aggressively clear flags during RevWalk.reset We cannot rely upon SEEN to tell us if the commit has flags we must clear, as some forms of RevWalk usage can get flags put in places that don't have a clear SEEN trail leading to them. To ensure we have correctly reset the graph we need to follow down any chain which has any flag we are not going to retain across the reset, making the correct test ~retain (and not just SEEN). This fixes an issue I identified in an application that makes heavy use of the same RevWalk instance, constantly resetting it and executing down different parts of the same DAG instance. Some executions still had UNINTERESTING colored on commits, even though they should have been cleared by the prior reset. The clear failed as there was not a SEEN path leading into the previously UNINTERESTING (but now interesting) commit. This missing SEEN path occurred because markUninteresting() runs RevComit.carryFlags(), pushing the UNINTERESTING flag as far down the DAG as we have parsed. Not all of those DAG nodes may get visited in a traversal (so they lack SEEN), but they must get reset in order to reuse the same DAG instance. Signed-off-by: Shawn O. Pearce Signed-off-by: Robin Rosenberg --- org.spearce.jgit/src/org/spearce/jgit/revwalk/RevWalk.java | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/org.spearce.jgit/src/org/spearce/jgit/revwalk/RevWalk.java b/org.spearce.jgit/src/org/spearce/jgit/revwalk/RevWalk.java index 5cd7f717..d7e4c587 100644 --- a/org.spearce.jgit/src/org/spearce/jgit/revwalk/RevWalk.java +++ b/org.spearce.jgit/src/org/spearce/jgit/revwalk/RevWalk.java @@ -887,10 +887,11 @@ public class RevWalk implements Iterable { protected void reset(int retainFlags) { finishDelayedFreeFlags(); retainFlags |= PARSED; + final int clearFlags = ~retainFlags; final FIFORevQueue q = new FIFORevQueue(); for (final RevCommit c : roots) { - if ((c.flags & SEEN) == 0) + if ((c.flags & clearFlags) == 0) continue; c.flags &= retainFlags; c.reset(); @@ -901,10 +902,13 @@ public class RevWalk implements Iterable { final RevCommit c = q.next(); if (c == null) break; + if (c.parents == null) + continue; for (final RevCommit p : c.parents) { - if ((p.flags & SEEN) == 0) + if ((p.flags & clearFlags) == 0) continue; p.flags &= retainFlags; + p.reset(); q.add(p); } } -- 2.11.4.GIT