]> source.dussan.org Git - gitblit.git/commitdiff
Avoid NPE when the default branch cannot be identified
authorRobin Rosenberg <robin.rosenberg@dewire.com>
Sun, 1 Sep 2013 17:58:00 +0000 (19:58 +0200)
committerRobin Rosenberg <robin.rosenberg@dewire.com>
Sun, 1 Sep 2013 17:58:00 +0000 (19:58 +0200)
This is a normal condition that complicates debugging, i.e.
when catching all NPE's.

src/main/java/com/gitblit/utils/JGitUtils.java

index 8676d748c6ff14df5614a1117b50c7d518a39835..3f01eeaf07c8c166e1bad170f52b93dd6815afc6 100644 (file)
@@ -566,6 +566,8 @@ public class JGitUtils {
                try {\r
                        if (tree == null) {\r
                                ObjectId object = getDefaultBranch(repository);\r
+                               if (object == null)\r
+                                       return null;\r
                                RevCommit commit = rw.parseCommit(object);\r
                                tree = commit.getTree();\r
                        }\r