git/list[1] front-page[2] threads[3] people[4] search[5] about
 

[JGIT PATCH 3/3] Use a common skipObject method to avoid UNINTERESTING items

From
Shawn O. Pearce <spearce@spearce.org>
Date
Mar 13, 2009, 18:11 UTC
Message-ID
<1236967912-15088-3-git-send-email-spearce@spearce.org>
In-Reply-To
<1236967912-15088-2-git-send-email-spearce@spearce.org>

All cases are using the same logic to decide that we should skip this current object and not return it to the caller. A common implementation makes the code easier to follow, especially as it reduces the ugly line wrap involved in the loop body.

Signed-off-by: Shawn O. Pearce <spearce@spearce.org>
---
 .../src/org/spearce/jgit/revwalk/ObjectWalk.java   |   12 +++++++-----
 1 files changed, 7 insertions(+), 5 deletions(-)
diff --git a/org.spearce.jgit/src/org/spearce/jgit/revwalk/ObjectWalk.java b/org.spearce.jgit/src/org/spearce/jgit/revwalk/ObjectWalk.java
index a481639..b92629e 100644
--- a/org.spearce.jgit/src/org/spearce/jgit/revwalk/ObjectWalk.java
+++ b/org.spearce.jgit/src/org/spearce/jgit/revwalk/ObjectWalk.java
@@ -255,8 +255,7 @@ public RevObject nextObject() throws MissingObjectException,
 				if ((o.flags & SEEN) != 0)
 					break;
 				o.flags |= SEEN;
-				if ((o.flags & UNINTERESTING) != 0
-						&& !hasRevSort(RevSort.BOUNDARY))
+				if (skipObject(o))
 					break;
 				fromTreeWalk = true;
 				return o;
@@ -267,8 +266,7 @@ public RevObject nextObject() throws MissingObjectException,
 				if ((o.flags & SEEN) != 0)
 					break;
 				o.flags |= SEEN;
-				if ((o.flags & UNINTERESTING) != 0
-						&& !hasRevSort(RevSort.BOUNDARY))
+				if (skipObject(o))
 					break;
 				nextSubtree = o;
 				fromTreeWalk = true;
@@ -294,7 +292,7 @@ public RevObject nextObject() throws MissingObjectException,
 			if ((o.flags & SEEN) != 0)
 				continue;
 			o.flags |= SEEN;
-			if ((o.flags & UNINTERESTING) != 0 && !hasRevSort(RevSort.BOUNDARY))
+			if (skipObject(o))
 				continue;
 			if (o instanceof RevTree) {
 				currentTree = (RevTree) o;
@@ -304,6 +302,10 @@ public RevObject nextObject() throws MissingObjectException,
 		}
 	}
 
+	private final boolean skipObject(final RevObject o) {
+		return (o.flags & UNINTERESTING) != 0 && !hasRevSort(RevSort.BOUNDARY);
+	}
+
 	/**
 	 * Verify all interesting objects are available, and reachable.
 	 * <p>
-- 
1.6.2.288.gc3f22
Previous: Shawn O. PearceNext: Robin Rosenberg
Message 3 of 6 in “Add lookupBlob to RevWalk”
  1. 1/3 Add lookupBlob to RevWalkShawn O. Pearce, Mar 13, 2009
  2. 2/3 Fix ObjectWalk to handle single-entry subtrees correctlyShawn O. Pearce, Mar 13, 2009
  3. 3/3 Use a common skipObject method to avoid UNINTERESTING itemsShawn O. Pearce, Mar 13, 2009
  4. Robin RosenbergMar 15, 2009
  5. Shawn O. PearceMar 16, 2009
  6. Shawn O. PearceMar 13, 2009

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.