git/list[1] front-page[2] threads[3] people[4] search[5] about
 

Re: Why does "merge --continue" expect no arguments?

From
Junio C Hamano <gitster@pobox.com>
Date
Dec 21, 2021, 17:13 UTC
Message-ID
<xmqqlf0dq3t3.fsf@gitster.g>
In-Reply-To
<CALRdAfcyfesNqfLhhe2GW_5V9s2hf++i6mZS1Lw5hqQYTca85w@mail.gmail.com>
Daniel Vicarel <shundra8820@gmail.com> writes:
Show 9 quoted lines
> There are several git commands that take a "--continue"
> option...`merge`, `rebase`, `cherry-pick`, etc. From looking through
> the source though, only `merge --continue` seems to expect no other
> arguments. Suppose that you have just resolved some merge conflicts,
> and then want to run `git merge --continue --no-edit` to accept the
> default merge commit message. Having to open/close the configured text
> editor still is mildly annoying. I'm interested in submitting a patch
> to "fix" this `merge` behavior, but I wanted to check if this was
> really the intended behavior first, and if so why.

The answer lies somewhere between "it is very much deliberate" and "'merge --continue' is so unimportant that nobody bothered".

Originally, our "merge" did not open an editor to give you a chance to explain why you are merging a side branch when recording a cleanly auto-resolved result. In fact, it didn't even have an "--edit" option to optionally allow you to edit. This changed at f8246281 (merge: use editor by default in interactive sessions, 2012-01-10); its log message is worth a read to understand the issues.

Compared to a merge that cleanly auto-resolved, in a conflicted merge, you have one more thing worth explaining to future readers of "git log"---how and why the work on the side branch conflicted with the work on the mainline, and how you chose to resolve it.

So, in that sense, we would very much want to do whatever possible to encourage you to write a good log message. Opening an editor is one step in that direction.

Among the commands with "--continue", "merge --continue" came much later, and it did not even need to exist. The other commands with "--continue", e.g. "rebase", deal with multi-step operations, and it is worth to have a way to say "I am finished with this step, let's CONTINUE WITH THE REST". But in "merge", there is no remaining thing to do after you are done with the conflict you saw.

In hindsight, we probably should have resisted the urge to add "merge --continue", just for the sake of misguided "consistency" perceived on non-existent similarity with other commands that truly need "--continue". What is called "merge --continue" should have been called "merge --finish", if we needed to add something back then.

The way to finish a conflicted merge has always been to run "git commit" before "merge --continue" was added, and it still is not just accepted but is the right way to finish a conflicted merge.

So, in that sense, "merge --continue" is so unimportant that it is understandable that nobody bothered.

So I guess that makes two discouraging factors against adding "--no-edit" to "merge --continue". It encourages a wrong behaviour of under-explaining the result of your work, and "commit" is a much shorter way to say "merge --continue" anyway.

In fact, "merge --continue --no-edit" is much longer to type than "commit --no-edit".

merge --continue commit --no-edit

Having said all that, among various things that the above discussion suggests as possible next steps, i.e.

 * deprecate and eventually remove "merge --continue"
 * deprecate and eventually rename "merge --continue" to "merge --finish"
 * add "--no-edit" to "merge --continue"

I think the last one might be the change with least impact and resistance. Those who are unaware that "commit --no-edit" suffices would end up typing a lot more and wasting their keyswitches' life, but the damage is limited ;-)

Or we could throw in another
 * document more clearly that "merge --continue" is a mere synonym
   for, and hint that there is no reason to favor it over, "git
   commit".

which happens to be my favourite so far after thinking the above through.

Thanks.
Previous: Daniel VicarelNext: Daniel Vicarel
Message 2 of 12 in “Why does "merge --continue" expect no arguments?”
  1. Daniel VicarelDec 21, 2021
  2. Junio C HamanoDec 21, 2021
  3. Daniel VicarelDec 21, 2021
  4. Daniel VicarelDec 21, 2021
  5. Junio C HamanoDec 22, 2021
  6. Philip OakleyDec 21, 2021
  7. Ævar Arnfjörð BjarmasonDec 24, 2021
  8. Junio C HamanoDec 25, 2021
  9. Ævar Arnfjörð BjarmasonDec 26, 2021
  10. Junio C HamanoDec 27, 2021
  11. Daniel VicarelDec 23, 2021
  12. Junio C HamanoDec 23, 2021

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.