git.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: "Shawn O. Pearce" <spearce@spearce.org>
To: Robin Rosenberg <robin.rosenberg@dewire.com>
Cc: git@vger.kernel.org
Subject: [JGIT PATCH 2/2] More aggressively clear flags during RevWalk.reset
Date: Tue, 16 Sep 2008 12:34:37 -0700	[thread overview]
Message-ID: <1221593677-24481-2-git-send-email-spearce@spearce.org> (raw)
In-Reply-To: <1221593677-24481-1-git-send-email-spearce@spearce.org>

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 <spearce@spearce.org>
---
 .../src/org/spearce/jgit/revwalk/RevWalk.java      |    8 ++++++--
 1 files 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 5cd7f71..d7e4c58 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 final void resetRetain(final RevFlag... retainFlags) {
 	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 @@ protected void reset(int retainFlags) {
 			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);
 			}
 		}
-- 
1.6.0.2.389.g421e0

      reply	other threads:[~2008-09-16 19:35 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2008-09-16 19:34 [JGIT PATCH 1/2] Paper bag fix RevWalk.reset after inMergeBase is used Shawn O. Pearce
2008-09-16 19:34 ` Shawn O. Pearce [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1221593677-24481-2-git-send-email-spearce@spearce.org \
    --to=spearce@spearce.org \
    --cc=git@vger.kernel.org \
    --cc=robin.rosenberg@dewire.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).