From: Shawn O. Pearce Date: Fri, 13 Mar 2009 18:11:52 GMT Subject: [JGIT PATCH 3/3] Use a common skipObject method to avoid UNINTERESTING items 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 --- .../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. *

-- 1.6.2.288.gc3f22