diff --git a/org.eclipse.jgit.test/tst/org/eclipse/jgit/api/CommitOnlyTest.java b/org.eclipse.jgit.test/tst/org/eclipse/jgit/api/CommitOnlyTest.java index bbd6ec0bd..43c00518a 100644 --- a/org.eclipse.jgit.test/tst/org/eclipse/jgit/api/CommitOnlyTest.java +++ b/org.eclipse.jgit.test/tst/org/eclipse/jgit/api/CommitOnlyTest.java @@ -1294,9 +1294,15 @@ public class CommitOnlyTest extends RepositoryTestCase { try { final Repository repo = git.getRepository(); final ObjectId headId = repo.resolve(Constants.HEAD + "^{commit}"); + if (headId == null) { + return ""; + } try (RevWalk rw = new RevWalk(repo)) { final TreeWalk tw = TreeWalk.forPath(repo, path, rw.parseTree(headId)); + if (tw == null) { + return ""; + } return new String(tw.getObjectReader().open(tw.getObjectId(0)) .getBytes()); }