You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I tried to get a non-existent commit.
In my case it was HEAD on an orphaned branch where naturally no head reference is present, the same should happen on a newly initialized repository though.
In that situation I called Grgit.head() which resulted in the following exception:
Caused by: java.lang.NullPointerException
at org.eclipse.jgit.lib.Repository.resolve(Repository.java:531)
at org.eclipse.jgit.lib.Repository.resolve(Repository.java:492)
at org.eclipse.jgit.lib.Repository$resolve.call(Unknown Source)
at org.eclipse.jgit.lib.Repository$resolve.call(Unknown Source)
at org.ajoberstar.grgit.util.JGitUtil.resolveObject(JGitUtil.groovy:43)
at org.ajoberstar.grgit.util.JGitUtil.resolveCommit(JGitUtil.groovy:86)
at org.ajoberstar.grgit.util.JGitUtil$resolveCommit$0.callStatic(Unknown Source)
at org.ajoberstar.grgit.util.JGitUtil.resolveCommit(JGitUtil.groovy:87)
at org.ajoberstar.grgit.util.JGitUtil$resolveCommit$0.call(Unknown Source)
at org.ajoberstar.grgit.service.ResolveService.toCommit(ResolveService.groovy:78)
at org.ajoberstar.grgit.service.ResolveService$toCommit.call(Unknown Source)
at org.ajoberstar.grgit.Grgit.head(Grgit.groovy:138)
The reason is in org.ajoberstar.grgit.util.JGitUtil#resolveCommit(org.ajoberstar.grgit.Repository, java.lang.String):
resolveObject for a string that cannot be resolved to an object id returns null according to situation and also its JavaDoc. resolveCommit(repo, id) then recursively calls itself (not the object id overload like it would be in Java) which then results in the call resolveObject(repo, null) which then ultimately throws the NullPointerException.
I tried to get a non-existent commit.
In my case it was
HEAD
on an orphaned branch where naturally no head reference is present, the same should happen on a newly initialized repository though.In that situation I called
Grgit.head()
which resulted in the following exception:The reason is in
org.ajoberstar.grgit.util.JGitUtil#resolveCommit(org.ajoberstar.grgit.Repository, java.lang.String)
:resolveObject
for a string that cannot be resolved to an object id returnsnull
according to situation and also its JavaDoc.resolveCommit(repo, id)
then recursively calls itself (not the object id overload like it would be in Java) which then results in the callresolveObject(repo, null)
which then ultimately throws theNullPointerException
.I guess the correct fix would be
The text was updated successfully, but these errors were encountered: