Fix NPE in MergeOp when submit to new branch fails due to dependencies
This resolves the stack trace reported in GERRIT-192, where we hit an
NPE because mergeTip was still null, as no changes were chosen to be
merged into the stillborn branch, due to missing dependencies.
Bug: GERRIT-192
Signed-off-by: Shawn O. Pearce <sop@google.com>
diff --git a/src/main/java/com/google/gerrit/git/MergeOp.java b/src/main/java/com/google/gerrit/git/MergeOp.java
index 939b0ef..9d40429 100644
--- a/src/main/java/com/google/gerrit/git/MergeOp.java
+++ b/src/main/java/com/google/gerrit/git/MergeOp.java
@@ -421,6 +421,14 @@
}
private void markCleanMerges() throws MergeException {
+ if (mergeTip == null) {
+ // If mergeTip is null here, branchTip was null, indicating a new branch
+ // at the start of the merge process. We also elected to merge nothing,
+ // probably due to missing dependencies. Nothing was cleanly merged.
+ //
+ return;
+ }
+
try {
rw.reset();
rw.sort(RevSort.TOPO);