]> source.dussan.org Git - jgit.git/commitdiff
Fix NPE in CommitOnlyTest#getHead 62/147862/8
authorMatthias Sohn <matthias.sohn@sap.com>
Fri, 16 Aug 2019 22:17:51 +0000 (00:17 +0200)
committerMatthias Sohn <matthias.sohn@sap.com>
Sun, 18 Aug 2019 09:59:54 +0000 (11:59 +0200)
Change-Id: I05abd00d151cf9834d1a097dd16dc280b62a7edd
Signed-off-by: Matthias Sohn <matthias.sohn@sap.com>
org.eclipse.jgit.test/tst/org/eclipse/jgit/api/CommitOnlyTest.java

index bbd6ec0bde84c0d1ed4e5c8c31183a61769aa9bc..43c00518a61013945e73a214ff79754e737add21 100644 (file)
@@ -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());
                        }