commit 35d2583f834a66f801dc229002d45e735882ba78 from: Stefan Sperling date: Mon Apr 17 15:53:19 2023 UTC allow no-op merge commits to be created Requested by James Cook commit - 2b70695630ead3274d31727f6b477f3544dc9c9a commit + 35d2583f834a66f801dc229002d45e735882ba78 blob - c924075eacdb3d7e5ebe3fc11b3c59262e7e120f blob + 923e489c4fb37899470241b32f5235c9b6652c87 --- got/got.1 +++ got/got.1 @@ -2851,10 +2851,6 @@ The work tree may be modified as desired and the merge once the changes present in the work tree are considered complete. Alternatively, the merge operation may be aborted which will leave the work tree's current branch unmodified. -.Pp -If a merge conflict is resolved in a way which renders all merged -changes into no-op changes, the merge operation cannot continue -and must be aborted. .Pp .Cm got merge will refuse to run if certain preconditions are not met. blob - 2bc8caf5426fa97b5db0fe63e371b0cbd9347786 blob + 622c0ce1ca669ed14ca0d26259483e9beea95863 --- lib/worktree.c +++ lib/worktree.c @@ -8388,13 +8388,7 @@ got_worktree_merge_commit(struct got_object_id **new_c err = worktree_status(worktree, "", fileindex, repo, collect_commitables, &cc_arg, NULL, NULL, 1, 0); if (err) - goto done; - - if (TAILQ_EMPTY(&commitable_paths)) { - err = got_error_fmt(GOT_ERR_COMMIT_NO_CHANGES, - "merge of %s cannot proceed", branch_name); goto done; - } TAILQ_FOREACH(pe, &commitable_paths, entry) { struct got_commitable *ct = pe->data; blob - 9093dd5b9fb524b14d2d17d4fe754da0ec8ef9f4 blob + 11ffa61f4a12efd380087a03aa5b186b9a745ae2 --- regress/cmdline/merge.sh +++ regress/cmdline/merge.sh @@ -1045,7 +1045,7 @@ test_merge_no_op() { (cd $testroot/repo && git checkout -q -b newbranch) echo "modified alpha on branch" > $testroot/repo/alpha git_commit $testroot/repo -m "committing to alpha on newbranch" - local branch_commitk=`git_show_branch_head $testroot/repo newbranch` + local branch_commit=`git_show_branch_head $testroot/repo newbranch` got checkout -b master $testroot/repo $testroot/wt > /dev/null ret=$? @@ -1122,19 +1122,30 @@ test_merge_no_op() { (cd $testroot/wt && got merge -c > $testroot/stdout \ 2> $testroot/stderr) ret=$? - if [ $ret -eq 0 ]; then - echo "got merge succeeded unexpectedly" >&2 + if [ $ret -ne 0 ]; then + echo "got merge failed unexpectedly" >&2 test_done "$testroot" "$ret" return 1 fi - echo -n "got: merge of refs/heads/newbranch cannot proceed: " \ - > $testroot/stderr.expected - echo "no changes to commit" >> $testroot/stderr.expected + echo -n '' > $testroot/stderr.expected cmp -s $testroot/stderr.expected $testroot/stderr ret=$? if [ $ret -ne 0 ]; then diff -u $testroot/stderr.expected $testroot/stderr + test_done "$testroot" "$ret" + return 1 + fi + + local merge_commit=`git_show_head $testroot/repo` + echo -n "Merged refs/heads/newbranch into refs/heads/master: " \ + > $testroot/stdout.expected + echo $merge_commit >> $testroot/stdout.expected + + cmp -s $testroot/stdout.expected $testroot/stdout + ret=$? + if [ $ret -ne 0 ]; then + diff -u $testroot/stdout.expected $testroot/stdout test_done "$testroot" "$ret" return 1 fi @@ -1146,7 +1157,20 @@ test_merge_no_op() { ret=$? if [ $ret -ne 0 ]; then diff -u $testroot/stdout.expected $testroot/stdout + test_done "$testroot" "$ret" + return 1 fi + + # We should have created a merge commit with two parents. + got log -r $testroot/repo -l1 -c $merge_commit | grep ^parent \ + > $testroot/stdout + echo "parent 1: $master_commit" > $testroot/stdout.expected + echo "parent 2: $branch_commit" >> $testroot/stdout.expected + cmp -s $testroot/stdout.expected $testroot/stdout + ret=$? + if [ $ret -ne 0 ]; then + diff -u $testroot/stdout.expected $testroot/stdout + fi test_done "$testroot" "$ret" }