2222import org .locationtech .geogig .model .Ref ;
2323import org .locationtech .geogig .model .RevCommit ;
2424import org .locationtech .geogig .model .SymRef ;
25+ import org .locationtech .geogig .plumbing .CleanRefsOp ;
2526import org .locationtech .geogig .plumbing .DiffTree ;
2627import org .locationtech .geogig .plumbing .FindCommonAncestor ;
2728import org .locationtech .geogig .plumbing .RefParse ;
@@ -61,6 +62,8 @@ public class MergeOp extends AbstractGeoGigOp<MergeOp.MergeReport> {
6162
6263 private boolean theirs ;
6364
65+ private boolean continueMerge ;
66+
6467 private boolean noCommit ;
6568
6669 private boolean noFastForward ;
@@ -82,6 +85,8 @@ public class MergeOp extends AbstractGeoGigOp<MergeOp.MergeReport> {
8285
8386 private Ref origStageHead = null ;
8487
88+ private boolean abort ;
89+
8590 /**
8691 * @param message the message for the merge commit
8792 * @return {@code this}
@@ -106,6 +111,11 @@ public MergeOp addCommit(final ObjectId commit) {
106111 return this ;
107112 }
108113
114+ public MergeOp setAbort () {
115+ this .abort = true ;
116+ return this ;
117+ }
118+
109119 /**
110120 *
111121 * @param ours true if the "ours" strategy should be used
@@ -177,8 +187,11 @@ public MergeOp setFastForwardOnly(boolean fastForwardOnly) {
177187 */
178188 @ Override
179189 protected MergeReport _call () throws RuntimeException {
190+ if (abort ) {
191+ return abort ();
192+ }
180193 final List <ObjectId > commits = this .commits ;
181- checkArgument (commits .size () > 0 , "No commits specified for merge." );
194+ checkArgument (continueMerge || commits .size () > 0 , "No commits specified for merge." );
182195 checkArgument (!(ours && theirs ), "Cannot use both --ours and --theirs." );
183196 checkArgument (!(noFastForward && fastForwardOnly ), "Cannot use both --no-ff and --ff-only" );
184197
@@ -349,6 +362,12 @@ protected MergeReport _call() throws RuntimeException {
349362
350363 }
351364
365+ private MergeReport abort () {
366+ command (CleanRefsOp .class ).call ();
367+ conflictsDatabase ().removeConflicts (null );
368+ return null ;
369+ }
370+
352371 private Ref doFastForwardMerge (Ref headRef , ObjectId commitId ,
353372 MergeStatusBuilder mergeStatusBuilder ) {
354373 if (headRef instanceof SymRef ) {
0 commit comments