From: "Shawn O. Pearce" <spearce@spearce.org>
To: Robin Rosenberg <robin.rosenberg@dewire.com>
Cc: git@vger.kernel.org
Subject: Re: [JGIT PATCH 2/3] Fix ObjectWalk to handle single-entry subtrees correctly
Date: Fri, 13 Mar 2009 11:37:03 -0700 [thread overview]
Message-ID: <20090313183703.GG22920@spearce.org> (raw)
In-Reply-To: <1236967912-15088-2-git-send-email-spearce@spearce.org>
"Shawn O. Pearce" <spearce@spearce.org> wrote:
> diff --git a/org.spearce.jgit/src/org/spearce/jgit/treewalk/CanonicalTreeParser.java b/org.spearce.jgit/src/org/spearce/jgit/treewalk/CanonicalTreeParser.java
> index 8028b14..5c331ca 100644
> --- a/org.spearce.jgit/src/org/spearce/jgit/treewalk/CanonicalTreeParser.java
> +++ b/org.spearce.jgit/src/org/spearce/jgit/treewalk/CanonicalTreeParser.java
> @@ -145,8 +145,19 @@ public CanonicalTreeParser resetRoot(final Repository repo,
>
> /** @return this iterator, or its parent, if the tree is at eof. */
> public CanonicalTreeParser next() {
> - next(1);
> - return eof() && parent != null ? (CanonicalTreeParser) parent : this;
> + CanonicalTreeParser p = this;
> + for (;;) {
> + p.next(1);
> + if (p.eof() && parent != null) {
> + // Parent was left pointing at the entry for us; advance
> + // the parent to the next entry, possibly unwinding many
> + // levels up the tree.
> + //
> + p = (CanonicalTreeParser) p.parent;
> + continue;
> + }
> + return p;
> + }
The parent != null test is wrong, we need "p.parent" here:
diff --git a/org.spearce.jgit/src/org/spearce/jgit/treewalk/CanonicalTreeParser.java b/org.spearce.jgit/src/org/spearce/jgit/treewalk/CanonicalTreeParser.java
index 5c331ca..7f89cff 100644
--- a/org.spearce.jgit/src/org/spearce/jgit/treewalk/CanonicalTreeParser.java
+++ b/org.spearce.jgit/src/org/spearce/jgit/treewalk/CanonicalTreeParser.java
@@ -148,7 +148,7 @@ public CanonicalTreeParser next() {
CanonicalTreeParser p = this;
for (;;) {
p.next(1);
- if (p.eof() && parent != null) {
+ if (p.eof() && p.parent != null) {
// Parent was left pointing at the entry for us; advance
// the parent to the next entry, possibly unwinding many
// levels up the tree.
--
Shawn.
prev parent reply other threads:[~2009-03-13 18:38 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2009-03-13 18:11 [JGIT PATCH 1/3] Add lookupBlob to RevWalk Shawn O. Pearce
2009-03-13 18:11 ` [JGIT PATCH 2/3] Fix ObjectWalk to handle single-entry subtrees correctly Shawn O. Pearce
2009-03-13 18:11 ` [JGIT PATCH 3/3] Use a common skipObject method to avoid UNINTERESTING items Shawn O. Pearce
2009-03-15 0:25 ` Robin Rosenberg
2009-03-16 14:13 ` Shawn O. Pearce
2009-03-13 18:37 ` 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=20090313183703.GG22920@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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.