aboutsummaryrefslogtreecommitdiffstats
path: root/org.eclipse.jgit.junit
diff options
context:
space:
mode:
authorMatthias Sohn <matthias.sohn@sap.com>2024-11-07 23:35:13 +0100
committerMatthias Sohn <matthias.sohn@sap.com>2024-11-07 23:35:30 +0100
commit958d053920a27ee1de0b5290099e4f7149de2c4b (patch)
treec5b968f876e6d2ecc536336e331d8ee2c18b2403 /org.eclipse.jgit.junit
parent3a7a9cb0e89de263d0a5133949c9c9bed5141916 (diff)
downloadjgit-958d053920a27ee1de0b5290099e4f7149de2c4b.tar.gz
jgit-958d053920a27ee1de0b5290099e4f7149de2c4b.zip
Enhance CommitBuilder#parent to tolerate null parent
Change-Id: Ifdeafd040bca8331804c3e7568da0bee5cbd01df
Diffstat (limited to 'org.eclipse.jgit.junit')
-rw-r--r--org.eclipse.jgit.junit/src/org/eclipse/jgit/junit/TestRepository.java10
1 files changed, 7 insertions, 3 deletions
diff --git a/org.eclipse.jgit.junit/src/org/eclipse/jgit/junit/TestRepository.java b/org.eclipse.jgit.junit/src/org/eclipse/jgit/junit/TestRepository.java
index a2e0a571eb..66cf739ef1 100644
--- a/org.eclipse.jgit.junit/src/org/eclipse/jgit/junit/TestRepository.java
+++ b/org.eclipse.jgit.junit/src/org/eclipse/jgit/junit/TestRepository.java
@@ -30,6 +30,7 @@ import java.util.List;
import java.util.Set;
import java.util.TimeZone;
+import org.eclipse.jgit.annotations.Nullable;
import org.eclipse.jgit.api.Git;
import org.eclipse.jgit.dircache.DirCache;
import org.eclipse.jgit.dircache.DirCacheBuilder;
@@ -1144,15 +1145,18 @@ public class TestRepository<R extends Repository> implements AutoCloseable {
}
/**
- * set parent commit
+ * Set parent commit
*
* @param p
- * parent commit
+ * parent commit, can be {@code null}
* @return this commit builder
* @throws Exception
* 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()) {
DirCacheBuilder b = tree.builder();
parseBody(p);