diff options
author | Jonathan Nieder <jrn@google.com> | 2020-03-02 13:37:59 -0500 |
---|---|---|
committer | Gerrit Code Review @ Eclipse.org <gerrit@eclipse.org> | 2020-03-02 13:37:59 -0500 |
commit | fb45137a7ca2d4f56ffd1a799c44a9e0d1c7e40c (patch) | |
tree | 0c99a303abf7b1d5339533a0f17319713e6a70fd | |
parent | 8f961240f11340009ab86914e67cd2104c46f28d (diff) | |
parent | 7ba261fb5f516dce83adc6f3bd4ac1666a51193e (diff) | |
download | jgit-fb45137a7ca2d4f56ffd1a799c44a9e0d1c7e40c.tar.gz jgit-fb45137a7ca2d4f56ffd1a799c44a9e0d1c7e40c.zip |
Merge "ObjectWalk: Add null check before skip tree."
-rw-r--r-- | org.eclipse.jgit.test/tst/org/eclipse/jgit/revwalk/ObjectWalkTest.java | 8 | ||||
-rw-r--r-- | org.eclipse.jgit/src/org/eclipse/jgit/revwalk/ObjectWalk.java | 4 |
2 files changed, 11 insertions, 1 deletions
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 a3bfb71e40..da7b266125 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 class ObjectWalkTest extends RevWalkTestCase { 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 21ce78e7e9..04a4b4c631 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 class ObjectWalk extends RevWalk { * @since 5.4 */ public void skipTree() { - currVisit.ptr = currVisit.buf.length; + if (currVisit != null) { + currVisit.ptr = currVisit.buf.length; + } } /** |