commit | 7ba261fb5f516dce83adc6f3bd4ac1666a51193e | [log] [tgz] |
---|---|---|
author | Yunjie Li <yunjieli@google.com> | Tue Feb 25 17:29:38 2020 -0800 |
committer | Yunjie Li <yunjieli@google.com> | Wed Feb 26 12:03:58 2020 -0800 |
tree | a8b95b6e3922dd213ecf84cb9d2cab84609e2b90 | |
parent | f63583928fc1784a98082e46fcb5d8c5445afb08 [diff] |
ObjectWalk: Add null check before skip tree. currVisit could be null if a blob is marked as start point in ObjectWalk. Add null check before skipping current tree. Change-Id: Ic5d876fe2800f3373d136979be6c27d1bbd38dc1 Signed-off-by: Yunjie Li <yunjieli@google.com>
diff --git a/org.eclipse.jgit.test/tst/org/eclipse/jgit/revwalk/ObjectWalkTest.java b/org.eclipse.jgit.test/tst/org/eclipse/jgit/revwalk/ObjectWalkTest.java index a3bfb71..da7b266 100644 --- a/org.eclipse.jgit.test/tst/org/eclipse/jgit/revwalk/ObjectWalkTest.java +++ b/org.eclipse.jgit.test/tst/org/eclipse/jgit/revwalk/ObjectWalkTest.java
@@ -216,4 +216,12 @@ public void testEmptyTreeCorruption() throws Exception { assertSame(rw.lookupBlob(bId), objw.nextObject()); assertNull(objw.nextObject()); } + + @Test + public void testSkipTreeWhenStartFromBlob() throws Exception { + final RevBlob f1 = blob("1"); + objw.markStart(f1); + assertSame(f1, objw.nextObject()); + objw.skipTree(); + } }
diff --git a/org.eclipse.jgit/src/org/eclipse/jgit/revwalk/ObjectWalk.java b/org.eclipse.jgit/src/org/eclipse/jgit/revwalk/ObjectWalk.java index 21ce78e..04a4b4c 100644 --- a/org.eclipse.jgit/src/org/eclipse/jgit/revwalk/ObjectWalk.java +++ b/org.eclipse.jgit/src/org/eclipse/jgit/revwalk/ObjectWalk.java
@@ -364,7 +364,9 @@ public RevCommit next() throws MissingObjectException, * @since 5.4 */ public void skipTree() { - currVisit.ptr = currVisit.buf.length; + if (currVisit != null) { + currVisit.ptr = currVisit.buf.length; + } } /**