Skip to content
Snippets Groups Projects
Commit 958d0539 authored by Matthias Sohn's avatar Matthias Sohn
Browse files

Enhance CommitBuilder#parent to tolerate null parent

Change-Id: Ifdeafd040bca8331804c3e7568da0bee5cbd01df
parent 3a7a9cb0
No related branches found
No related tags found
No related merge requests found
...@@ -30,6 +30,7 @@ ...@@ -30,6 +30,7 @@
import java.util.Set; import java.util.Set;
import java.util.TimeZone; import java.util.TimeZone;
import org.eclipse.jgit.annotations.Nullable;
import org.eclipse.jgit.api.Git; import org.eclipse.jgit.api.Git;
import org.eclipse.jgit.dircache.DirCache; import org.eclipse.jgit.dircache.DirCache;
import org.eclipse.jgit.dircache.DirCacheBuilder; import org.eclipse.jgit.dircache.DirCacheBuilder;
...@@ -1144,15 +1145,18 @@ public class CommitBuilder { ...@@ -1144,15 +1145,18 @@ public class CommitBuilder {
} }
/** /**
* set parent commit * Set parent commit
* *
* @param p * @param p
* parent commit * parent commit, can be {@code null}
* @return this commit builder * @return this commit builder
* @throws Exception * @throws Exception
* if an error occurred * if an error occurred
*/ */
public CommitBuilder parent(RevCommit p) throws Exception { public CommitBuilder parent(@Nullable RevCommit p) throws Exception {
if (p == null) {
return this;
}
if (parents.isEmpty()) { if (parents.isEmpty()) {
DirCacheBuilder b = tree.builder(); DirCacheBuilder b = tree.builder();
parseBody(p); parseBody(p);
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment