commit d8a7bd7ded08798e7d38e6706fbc540edce788f6 from: James Cook via: Thomas Adam date: Thu Jun 01 10:18:37 2023 UTC make "got merge" refuse to run if a merge is in progress and the -a or -c option wasn't passed. Patch by James Cook. commit - fb0cb7081e7276c006444afb9f9decbab6bedaff commit + d8a7bd7ded08798e7d38e6706fbc540edce788f6 blob - 928db41b2a98d23cf258b36c3c65174fb6c24ce7 blob + dbb0f4dedea82d8900cac49dd15046480d6cc5e6 --- got/got.c +++ got/got.c @@ -13238,13 +13238,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) @@ -13262,10 +13268,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