diff options
Diffstat (limited to 'org.eclipse.egit.gitflow/src/org/eclipse/egit/gitflow/GitFlowRepository.java')
-rw-r--r-- | org.eclipse.egit.gitflow/src/org/eclipse/egit/gitflow/GitFlowRepository.java | 12 |
1 files changed, 9 insertions, 3 deletions
diff --git a/org.eclipse.egit.gitflow/src/org/eclipse/egit/gitflow/GitFlowRepository.java b/org.eclipse.egit.gitflow/src/org/eclipse/egit/gitflow/GitFlowRepository.java index bd8b66901b..eaf6ada3e7 100644 --- a/org.eclipse.egit.gitflow/src/org/eclipse/egit/gitflow/GitFlowRepository.java +++ b/org.eclipse.egit.gitflow/src/org/eclipse/egit/gitflow/GitFlowRepository.java @@ -18,6 +18,7 @@ import java.util.List; import org.eclipse.egit.gitflow.internal.CoreText; import org.eclipse.jdt.annotation.NonNull; +import org.eclipse.jdt.annotation.Nullable; import org.eclipse.jgit.api.Git; import org.eclipse.jgit.api.errors.GitAPIException; import org.eclipse.jgit.errors.IncorrectObjectTypeException; @@ -158,12 +159,17 @@ public class GitFlowRepository { /** * @param branchName - * @return HEAD commit on branch branchName + * @return HEAD commit on branch branchName or {@literal null} if + * {@code branchName} could not be resolved. */ - public RevCommit findHead(String branchName) { + public @Nullable RevCommit findHead(String branchName) { try (RevWalk walk = new RevWalk(repository)) { try { - ObjectId head = repository.resolve(R_HEADS + branchName); + String revstr = R_HEADS + branchName; + ObjectId head = repository.resolve(revstr); + if (head == null) { + return null; + } return walk.parseCommit(head); } catch (RevisionSyntaxException | IOException e) { throw new RuntimeException(e); |