Commit Diff


commit - fb307946174c95e32d2048584c6ab1ce24f3ea00
commit + 427615296bc79cda685540d7fc241444b7447980
blob - 123dedc51cae9b07a29394e9816496121697cf7a
blob + f4666b0aa2b87365b32db745d93c6feae807d6a4
--- got/got.c
+++ got/got.c
@@ -13239,13 +13239,19 @@ cmd_merge(int argc, char *argv[])
 	error = got_worktree_merge_in_progress(&merge_in_progress, worktree,
 	    repo);
 	if (error)
+		goto done;
+
+	if (merge_in_progress && !(abort_merge || continue_merge)) {
+		error = got_error(GOT_ERR_MERGE_BUSY);
+		goto done;
+	}
+
+	if (!merge_in_progress && (abort_merge || continue_merge)) {
+		error = got_error(GOT_ERR_NOT_MERGING);
 		goto done;
+	}
 
 	if (abort_merge) {
-		if (!merge_in_progress) {
-			error = got_error(GOT_ERR_NOT_MERGING);
-			goto done;
-		}
 		error = got_worktree_merge_continue(&branch_name,
 		    &branch_tip, &fileindex, worktree, repo);
 		if (error)
@@ -13263,10 +13269,6 @@ cmd_merge(int argc, char *argv[])
 		goto done;
 
 	if (continue_merge) {
-		if (!merge_in_progress) {
-			error = got_error(GOT_ERR_NOT_MERGING);
-			goto done;
-		}
 		error = got_worktree_merge_continue(&branch_name,
 		    &branch_tip, &fileindex, worktree, repo);
 		if (error)
blob - 11ffa61f4a12efd380087a03aa5b186b9a745ae2
blob + df6f2f9edf54a23ff9b1e9f05267a77673a4fbcf
--- regress/cmdline/merge.sh
+++ regress/cmdline/merge.sh
@@ -870,9 +870,15 @@ test_merge_in_progress() {
 	fi
 
 	for cmd in update commit histedit "rebase newbranch" \
-		"integrate newbranch" "stage alpha"; do
+		"integrate newbranch" "merge newbranch" "stage alpha"; do
 		(cd $testroot/wt && got $cmd > $testroot/stdout \
 			2> $testroot/stderr)
+		ret=$?
+		if [ $ret -eq 0 ]; then
+			echo "got $cmd succeeded unexpectedly" >&2
+			test_done "$testroot" "1"
+			return 1
+		fi
 
 		echo -n > $testroot/stdout.expected
 		cmp -s $testroot/stdout.expected $testroot/stdout