summaryrefslogtreecommitdiffstats
path: root/org.eclipse.jgit.test
diff options
context:
space:
mode:
authorMatthias Sohn <matthias.sohn@sap.com>2019-08-17 00:17:51 +0200
committerMatthias Sohn <matthias.sohn@sap.com>2019-08-18 11:59:54 +0200
commit41da8de001794dcd6a3e782c313cc65abe7d4392 (patch)
tree4361a1debd2a36c0db852add442f37c49821c33f /org.eclipse.jgit.test
parent31356f5d181ea1a1c43b44d9dfbe9e8e81aed984 (diff)
downloadjgit-41da8de001794dcd6a3e782c313cc65abe7d4392.tar.gz
jgit-41da8de001794dcd6a3e782c313cc65abe7d4392.zip
Fix NPE in CommitOnlyTest#getHead
Change-Id: I05abd00d151cf9834d1a097dd16dc280b62a7edd Signed-off-by: Matthias Sohn <matthias.sohn@sap.com>
Diffstat (limited to 'org.eclipse.jgit.test')
-rw-r--r--org.eclipse.jgit.test/tst/org/eclipse/jgit/api/CommitOnlyTest.java6
1 files changed, 6 insertions, 0 deletions
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 bbd6ec0bde..43c00518a6 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());
}