{"thread":{"id":"57483","subject":"Please add support for \"git merge --continue -S\"","startedAt":"2022-02-28T09:55:15Z","lastAt":"2022-02-28T23:45:24Z","messageCount":4,"participants":["Rolf Eike Beer","Ævar Arnfjörð Bjarmason","Junio C Hamano"],"isPatch":false,"patchVersion":null,"patchTotal":null},"messages":[{"id":"449738","messageId":"3769291.LUJhsIL6D6@mobilepool36.emlix.com","threadId":"57483","inReplyTo":null,"subject":"Please add support for \"git merge --continue -S\"","fromName":"Rolf Eike Beer","fromEmail":"eb@emlix.com","sentAt":"2022-02-28T09:48:14Z","receivedAt":"2022-02-28T09:55:15Z","isPatch":false,"sender":{"key":"eb@emlix.com","avatar":null},"body":"Hi,\n\nI usually sign my commits and merges. But when a merge has collisions I can't \ncontinue and sign in one step, because --continue and -S seem to be mutually \nexclusive. My way out is:\n\ngit merge --continue\ngit commit --amend --no-edit -S\n\n... but this could be a bit simpler. Or maybe --continue could remember if I \nhave passed \"-S\" to the original \"git merge\" command.\n\nRegards,\n\nEike\n-- \nRolf Eike Beer, emlix GmbH, https://www.emlix.com\nFon +49 551 30664-0, Fax +49 551 30664-11\nGothaer Platz 3, 37083 Göttingen, Germany\nSitz der Gesellschaft: Göttingen, Amtsgericht Göttingen HR B 3160\nGeschäftsführung: Heike Jordan, Dr. Uwe Kracke – Ust-IdNr.: DE 205 198 055\n\nemlix - smart embedded open source"},{"id":"449742","messageId":"220228.86fso35k61.gmgdl@evledraar.gmail.com","threadId":"57483","inReplyTo":"3769291.LUJhsIL6D6@mobilepool36.emlix.com","subject":"Re: Please add support for \"git merge --continue -S\"","fromName":"Ævar Arnfjörð Bjarmason","fromEmail":"avarab@gmail.com","sentAt":"2022-02-28T10:58:11Z","receivedAt":"2022-02-28T11:02:06Z","isPatch":false,"sender":{"key":"avarab@gmail.com","avatar":"https://avatars.githubusercontent.com/u/45301?v=4"},"body":"\nOn Mon, Feb 28 2022, Rolf Eike Beer wrote:\n\n> [[PGP Signed Part:Undecided]]\n> Hi,\n>\n> I usually sign my commits and merges. But when a merge has collisions I can't \n> continue and sign in one step, because --continue and -S seem to be mutually \n> exclusive. My way out is:\n>\n> git merge --continue\n> git commit --amend --no-edit -S\n>\n> ... but this could be a bit simpler. Or maybe --continue could remember if I \n> have passed \"-S\" to the original \"git merge\" command.\n>\n> Regards,\n\nYou can just drop the use of \"merge --continue\" entirely and use\n\"commit\" instead.\n\nCaveats related to this were recently discussed on-list:\nhttps://lore.kernel.org/git/CALRdAfcyfesNqfLhhe2GW_5V9s2hf++i6mZS1Lw5hqQYTca85w@mail.gmail.com/\n\nAs noted there I think this makes for confusing UI, but you should able to just:\n\n    git commit -S\n"},{"id":"449816","messageId":"xmqq1qzmy55g.fsf@gitster.g","threadId":"57483","inReplyTo":"220228.86fso35k61.gmgdl@evledraar.gmail.com","subject":"Re: Please add support for \"git merge --continue -S\"","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2022-02-28T22:53:31Z","receivedAt":"2022-02-28T22:53:42Z","isPatch":false,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"Ævar Arnfjörð Bjarmason <avarab@gmail.com> writes:\n\n> You can just drop the use of \"merge --continue\" entirely and use\n> \"commit\" instead.\n>\n> Caveats related to this were recently discussed on-list:\n> https://lore.kernel.org/git/CALRdAfcyfesNqfLhhe2GW_5V9s2hf++i6mZS1Lw5hqQYTca85w@mail.gmail.com/\n\nAh, that one.  We need to close the #leftoverbits on the topic.\nHere is a starter.\n\n----- >8 --------- >8 --------- >8 --------- >8 --------- >8 -----\nSubject: merge: 'git merge --continue' is merely 'git commit'\n\nAmong the commands with \"--continue\", \"merge --continue\" came much\nlater, and it did not even need to exist.  The other commands with\n\"--continue\", e.g. \"rebase\", deal with multi-step operations, and it\nis worth to have a way to say \"I am finished with this step, let's\nCONTINUE WITH THE REST\".  But in \"merge\", there is no remaining\nthing to do after you are done with the conflict you saw.\n\nIn hindsight, we probably should have resisted the urge to add\n\"merge --continue\", just for the sake of misguided \"consistency\"\nperceived on non-existent similarity with other commands that truly\nneed \"--continue\".  What is called \"merge --continue\" should have\nbeen called \"merge --finish\", if we needed to add something back\nthen.\n\nThe way to finish a conflicted merge has always been to run \"git\ncommit\" before \"merge --continue\" was added, and it still is not\njust accepted but is the right way to finish a conflicted merge.\n\nThere is an argument that it makes it somehow \"safer\" to use \"merge\n--continue\" because the command fails when there is no interrupted\nmerge going on, but what the user sees from \"git commit\" when there\nis and there is not interrupted merge are so different, there is not\nmuch \"safety\" benefit in practice.  We probably should deprecate and\neventually remove \"git merge --continue\" eventually, but one step at\na time.\n\nSigned-off-by: Junio C Hamano <gitster@pobox.com>\n---\n Documentation/git-merge.txt | 13 ++++++-------\n 1 file changed, 6 insertions(+), 7 deletions(-)\n\ndiff --git c/Documentation/git-merge.txt w/Documentation/git-merge.txt\nindex 3125473cc1..95f252598e 100644\n--- c/Documentation/git-merge.txt\n+++ w/Documentation/git-merge.txt\n@@ -122,9 +122,9 @@ list.\n \tstash entry will be saved to the stash list.\n \n --continue::\n-\tAfter a 'git merge' stops due to conflicts you can conclude the\n-\tmerge by running 'git merge --continue' (see \"HOW TO RESOLVE\n-\tCONFLICTS\" section below).\n+\tAfter a 'git merge' stops due to conflicts, you can conclude\n+\tthe merge with \"git commit\" (see \"HOW TO RESOLVE CONFLICTS\"\n+\tsection below).  'git merge --continue' is a synonym for it.\n \n <commit>...::\n \tCommits, usually other branch heads, to merge into our branch.\n@@ -326,10 +326,9 @@ After seeing a conflict, you can do two things:\n \n  * Resolve the conflicts.  Git will mark the conflicts in\n    the working tree.  Edit the files into shape and\n-   'git add' them to the index.  Use 'git commit' or\n-   'git merge --continue' to seal the deal. The latter command\n-   checks whether there is a (interrupted) merge in progress\n-   before calling 'git commit'.\n+   'git add' them to the index.  Use 'git commit' (or\n+   'git merge --continue', which stops if there is no \n+   interrupted merge in progress) to seal the deal.\n \n You can work through the conflict with a number of tools:\n \n"},{"id":"449820","messageId":"220301.86wnhe1rph.gmgdl@evledraar.gmail.com","threadId":"57483","inReplyTo":"xmqq1qzmy55g.fsf@gitster.g","subject":"Re: Please add support for \"git merge --continue -S\"","fromName":"Ævar Arnfjörð Bjarmason","fromEmail":"avarab@gmail.com","sentAt":"2022-02-28T23:28:39Z","receivedAt":"2022-02-28T23:45:24Z","isPatch":false,"sender":{"key":"avarab@gmail.com","avatar":"https://avatars.githubusercontent.com/u/45301?v=4"},"body":"\nOn Mon, Feb 28 2022, Junio C Hamano wrote:\n\n> Ævar Arnfjörð Bjarmason <avarab@gmail.com> writes:\n> [...]\n> There is an argument that it makes it somehow \"safer\" to use \"merge\n> --continue\" because the command fails when there is no interrupted\n> merge going on, but what the user sees from \"git commit\" when there\n> is and there is not interrupted merge are so different, there is not\n> much \"safety\" benefit in practice.  We probably should deprecate and\n> eventually remove \"git merge --continue\" eventually, but one step at\n> a time.\n\nIf you run \"git status\" it'll look like you have a bunch of stuff\nstaged, and it's easy to miss if it's telling you you're in a merge\nconflict or not (especially if it scrolls off the screen).\n\nIf we're just taking personal experience into account when deciding if\nsomething improves safety I've made that mistake more than once & more\nthan twice. I.e. done a parents=1 commit when I thought I was in a merge\n(maybe confused about what terminal I was in etc).\n\nIf someone with N number of commits in this project can make that\nmistake, I daresay it helps some regular users too :)\n\n> diff --git c/Documentation/git-merge.txt w/Documentation/git-merge.txt\n> index 3125473cc1..95f252598e 100644\n> --- c/Documentation/git-merge.txt\n> +++ w/Documentation/git-merge.txt\n> @@ -122,9 +122,9 @@ list.\n>  \tstash entry will be saved to the stash list.\n>  \n>  --continue::\n> -\tAfter a 'git merge' stops due to conflicts you can conclude the\n> -\tmerge by running 'git merge --continue' (see \"HOW TO RESOLVE\n> -\tCONFLICTS\" section below).\n> +\tAfter a 'git merge' stops due to conflicts, you can conclude\n> +\tthe merge with \"git commit\" (see \"HOW TO RESOLVE CONFLICTS\"\n> +\tsection below).  'git merge --continue' is a synonym for it.\n\nSaying it's a synonym isn't correct, and also now contradicts the last\nparagraph of the DESCRIPTION section. Saying something like:\n\n    'git merge --continue' will run 'git commit', after first checking\n    whether a conflicted merge is underway.\n\nWould be correct, consistent with DESCRIPTION, and basically paraphrases\nwhat it says there.\n\n>  <commit>...::\n>  \tCommits, usually other branch heads, to merge into our branch.\n> @@ -326,10 +326,9 @@ After seeing a conflict, you can do two things:\n>  \n>   * Resolve the conflicts.  Git will mark the conflicts in\n>     the working tree.  Edit the files into shape and\n> -   'git add' them to the index.  Use 'git commit' or\n> -   'git merge --continue' to seal the deal. The latter command\n> -   checks whether there is a (interrupted) merge in progress\n> -   before calling 'git commit'.\n> +   'git add' them to the index.  Use 'git commit' (or\n> +   'git merge --continue', which stops if there is no \n> +   interrupted merge in progress) to seal the deal.\n>  \n>  You can work through the conflict with a number of tools:\n\nI think the former hunk with a minor edit is an improvement, i.e. let's\nsay 'git commit' works too.\n\nBut losing the description of the difference between the two here in the\nmore detailed section, whose job it is to explain the minor details,\nmakes the documentation worse IMO.\n\nThe \"seal the deal\" wording in the pre-image is a bit odd and\ninconsistent with our general tone, that's worth changing.\n\nBut there should still be some variant of \"'merge --continue', unlike\n'commit' will abort if no merge is in progress\".\n\nAside: After the last time this came up & looking at this again I looked\nat some of the tests, and I'm entirely confused about what f8b863598c9\n(builtin/merge: honor commit-msg hook for merges, 2017-09-07) is talking\nabout.\n\nI.e. it's \"just a synonym\", but it seems to claim that \"merge\n--continue\" somehow remembers --allow-unrelated-histories, but not\n--no-verify (for which we have a TODO test).\n\nIf you're set on deprecating it, as opposed to us supporting \"merge\n--continue -S\" or whatever, amending/removing that TODO test seem like a\ngood addition.\n\nAlso, after this came up the other day I came up with this WIP to have\nthe \"reflog\" reflect what command we ran, just as we do with rebase.\n\nIMO that really makes the difference beween the two worth it. E.g. for\nmy git.git integration branch running 'git reflog' and seeing at a\nglance wheher something was a conflicted merge or not (as long as I\nconsistently use \"merge --continue\", which I do) really aids\nreadability:\n\ndiff --git a/builtin/merge.c b/builtin/merge.c\nindex 74e53cf20a7..3cbb47c96f9 100644\n--- a/builtin/merge.c\n+++ b/builtin/merge.c\n@@ -1362,6 +1362,7 @@ int cmd_merge(int argc, const char **argv, const char *prefix)\n \t\tif (!file_exists(git_path_merge_head(the_repository)))\n \t\t\tdie(_(\"There is no merge in progress (MERGE_HEAD missing).\"));\n \n \t\t/* Invoke 'git commit' */\n+\t\tsetenv(\"GIT_REFLOG_ACTION\", \"merge (continue)\", 0);\n \t\tret = cmd_commit(nargc, nargv, prefix);\n \t\tgoto done;\ndiff --git a/t/t7600-merge.sh b/t/t7600-merge.sh\nindex f0f6fda150b..f4a0b70a213 100755\n--- a/t/t7600-merge.sh\n+++ b/t/t7600-merge.sh\n@@ -772,6 +772,8 @@ test_expect_success 'completed merge (git merge --continue) with --no-commit and\n \tgit stash show -p MERGE_AUTOSTASH >actual &&\n \ttest_cmp expect actual &&\n \tgit merge --continue 2>err &&\n+\tgit reflog -1 >reflog &&\n+\tgrep -F \"merge (continue)\" reflog &&\n \ttest_i18ngrep \"Applied autostash.\" err &&\n \tgit show HEAD:file >merge-result &&\n \ttest_cmp result.1-5 merge-result &&\n\n\n"}]}