All of lore.kernel.org
 help / color / mirror / Atom feed
* Why does "merge --continue" expect no arguments?
@ 2021-12-21 14:50 Daniel Vicarel
  2021-12-21 17:13 ` Junio C Hamano
       [not found] ` <CAFOYHZC0r35mfOVUExHsBP5=URKFAt_wDTZ51pTc=XkXyogqKQ@mail.gmail.com>
  0 siblings, 2 replies; 12+ messages in thread
From: Daniel Vicarel @ 2021-12-21 14:50 UTC (permalink / raw)
  To: git

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.

Thanks,
Dan Vicarel (he/him)

^ permalink raw reply	[flat|nested] 12+ messages in thread

* Re: Why does "merge --continue" expect no arguments?
  2021-12-21 14:50 Why does "merge --continue" expect no arguments? Daniel Vicarel
@ 2021-12-21 17:13 ` Junio C Hamano
  2021-12-21 17:51   ` Daniel Vicarel
                     ` (2 more replies)
       [not found] ` <CAFOYHZC0r35mfOVUExHsBP5=URKFAt_wDTZ51pTc=XkXyogqKQ@mail.gmail.com>
  1 sibling, 3 replies; 12+ messages in thread
From: Junio C Hamano @ 2021-12-21 17:13 UTC (permalink / raw)
  To: Daniel Vicarel; +Cc: git

Daniel Vicarel <shundra8820@gmail.com> writes:

> 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.

^ permalink raw reply	[flat|nested] 12+ messages in thread

* Re: Why does "merge --continue" expect no arguments?
  2021-12-21 17:13 ` Junio C Hamano
@ 2021-12-21 17:51   ` Daniel Vicarel
  2021-12-21 17:54     ` Daniel Vicarel
  2021-12-22  6:20     ` Junio C Hamano
  2021-12-21 17:57   ` Philip Oakley
  2021-12-24 17:08   ` Ævar Arnfjörð Bjarmason
  2 siblings, 2 replies; 12+ messages in thread
From: Daniel Vicarel @ 2021-12-21 17:51 UTC (permalink / raw)
  To: Junio C Hamano; +Cc: git

Thank you so much for the detailed response! Brief side note...this is
my first time posting on the git mailing list (or any mailing list of
this kind!), so please educate me if I'm incorrectly quoting, using
reply/CC, or formatting lines (not sure if the mail server
automatically wraps lines after 72 chars)...

Junio C Hamano <gitster@pobox.com> writes:
> 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.

Fair point. I would argue that in my own personal projects, where I am
the only contributor, sometimes I just want to accept the default
merge message and move on.  However, one could apply that reasoning to
_every_ commit message in a personal project, and I certainly don't
believe in that... so yeah, you've given me something to think about.

Junio C Hamano <gitster@pobox.com> writes:
> 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.

That makes sense. TBH, I assumed that `merge --continue` _was_ the
preferred way to finish merging after conflicts simply b/c the option
exists! `commit --no-edit` definitely meets my immediate needs though,
so thank you for that suggestion.

Junio C Hamano <gitster@pobox.com> writes:
> [...] 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"
> [...]
> * document more clearly that "merge --continue" is a mere synonym
>  for, and hint that there is no reason to favor it over, "git
>  commit".

I agree that some clearer documentation around `merge --continue` is
worthwhile, to prevent other developers from thinking like myself.
Maybe a warning from the CLI after running `merge --continue`,
recommending `commit` usage instead? Such a warning suggests that the
option _should_ still be deprecated and removed in the future though.

I am still interested in making a contribution to git, so let me know
which option you would like me to move forward with at this time:
adding the CLI warning, or going straight to a deprecation. Unless of
course you're already on it. :)


On Tue, Dec 21, 2021 at 12:13 PM Junio C Hamano <gitster@pobox.com> wrote:
>
> Daniel Vicarel <shundra8820@gmail.com> writes:
>
> > 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.



-- 

Dan Vicarel

^ permalink raw reply	[flat|nested] 12+ messages in thread

* Re: Why does "merge --continue" expect no arguments?
  2021-12-21 17:51   ` Daniel Vicarel
@ 2021-12-21 17:54     ` Daniel Vicarel
  2021-12-22  6:20     ` Junio C Hamano
  1 sibling, 0 replies; 12+ messages in thread
From: Daniel Vicarel @ 2021-12-21 17:54 UTC (permalink / raw)
  To: Junio C Hamano; +Cc: git

Eesh, I guess Gmail does top-posting using the entire conversation
thus far... Apologies for the noise!

^ permalink raw reply	[flat|nested] 12+ messages in thread

* Re: Why does "merge --continue" expect no arguments?
  2021-12-21 17:13 ` Junio C Hamano
  2021-12-21 17:51   ` Daniel Vicarel
@ 2021-12-21 17:57   ` Philip Oakley
  2021-12-24 17:08   ` Ævar Arnfjörð Bjarmason
  2 siblings, 0 replies; 12+ messages in thread
From: Philip Oakley @ 2021-12-21 17:57 UTC (permalink / raw)
  To: Junio C Hamano, Daniel Vicarel; +Cc: git

On 21/12/2021 17:13, Junio C Hamano wrote:
> 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.
I'm all for including the "document more clearly" approach...

With or without the code change.

--
Philip

^ permalink raw reply	[flat|nested] 12+ messages in thread

* Re: Why does "merge --continue" expect no arguments?
  2021-12-21 17:51   ` Daniel Vicarel
  2021-12-21 17:54     ` Daniel Vicarel
@ 2021-12-22  6:20     ` Junio C Hamano
  1 sibling, 0 replies; 12+ messages in thread
From: Junio C Hamano @ 2021-12-22  6:20 UTC (permalink / raw)
  To: Daniel Vicarel; +Cc: git

Daniel Vicarel <shundra8820@gmail.com> writes:

> Fair point. I would argue that in my own personal projects, where I am
> the only contributor, sometimes I just want to accept the default
> merge message and move on.  However, one could apply that reasoning to
> _every_ commit message in a personal project, and I certainly don't
> believe in that... so yeah, you've given me something to think about.

Like everybody else, I've had my fair share of "personal projects"
that I was the only developer who lost interest in them in 6 months
to 2 years since their inception---after that nobody would care, and
in such projects, of course, I can remember what I was thinking when
I did some nonsensical change early in their history.  I can survive
sloppy and crappy messages.

But in other projects, I've learned that the author of a commit or a
merge with my name and e-mail address 6 months ago often is a total
stranger for me sitting in front of the display right now.

> I agree that some clearer documentation around `merge --continue` is
> worthwhile, to prevent other developers from thinking like myself.
> Maybe a warning from the CLI after running `merge --continue`,
> recommending `commit` usage instead? Such a warning suggests that the
> option _should_ still be deprecated and removed in the future though.
>
> I am still interested in making a contribution to git, so let me know
> which option you would like me to move forward with at this time:
> adding the CLI warning, or going straight to a deprecation. Unless of
> course you're already on it. :)

Welcome to the development community.

If you want a starter project, among those I listed, perhaps the doc
update would be the quickest one that offers the most to learn from,
as the first road block new developers seem to stumble on is not
coding standard and stuff but social interaction between the patch
submitter and reviewers.

Allowing some selected command line option given to "git merge
--continue" down to underlying "git commit" would be a lot harder
for somebody new to the codebase.  It might make sense to allow
things like "--no-edit" and "--no-verify" to be passed, but you
would never ever want to pass something like "--amend", or (even
worse) a pathspec.  And coming up with a sensible list of allowed
options and arguments would be quite hard.


^ permalink raw reply	[flat|nested] 12+ messages in thread

* Re: Why does "merge --continue" expect no arguments?
       [not found] ` <CAFOYHZC0r35mfOVUExHsBP5=URKFAt_wDTZ51pTc=XkXyogqKQ@mail.gmail.com>
@ 2021-12-23  6:07   ` Daniel Vicarel
  2021-12-23 18:35     ` Junio C Hamano
  0 siblings, 1 reply; 12+ messages in thread
From: Daniel Vicarel @ 2021-12-23  6:07 UTC (permalink / raw)
  To: Chris Packham; +Cc: GIT

Thanks for the input, all.

Junio C Hamano <gitster@pobox.com> writes:
> perhaps the doc update would be the quickest one that offers the most to learn from

Sounds good! Now by "doc update" do you mean updating docs in the
Documentation/ folder, or adding a warning to the CLI output of `git
merge --continue`?

Junio C Hamano <gitster@pobox.com> writes:
> coming up with a sensible list of allowed options and arguments [to `git merge --continue`] would be quite hard.

Chris Packham <judge.packham@gmail.com> writes:
> I think it'd be a good idea to allow [--no-edit on `git merge --continue`] as long as it's the only other option allowed with --continue.

Based on these two pieces of feedback, it sounds like adding _just_
the `--no-edit` option at this point to `git merge --continue` is
worthwhile, and hopefully approachable for a newb. For now I'll put a
pin in it though, and focus on the documentation task above.


On Wed, Dec 22, 2021 at 2:46 AM Chris Packham <judge.packham@gmail.com> wrote:
>
> Hi Daniel,
>
> On Wed, 22 Dec 2021, 2:54 PM Daniel Vicarel, <shundra8820@gmail.com> wrote:
>>
>> 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.
>
>
> I added the --continue option to merge and I can tell you there was no reason --no-edit was omitted, I just didn't think of it at the time. I think it'd be a good idea to allow it as long as it's the only other option allowed with --continue.
>>
>>
>> Thanks,
>> Dan Vicarel (he/him)



-- 

Dan Vicarel

^ permalink raw reply	[flat|nested] 12+ messages in thread

* Re: Why does "merge --continue" expect no arguments?
  2021-12-23  6:07   ` Daniel Vicarel
@ 2021-12-23 18:35     ` Junio C Hamano
  0 siblings, 0 replies; 12+ messages in thread
From: Junio C Hamano @ 2021-12-23 18:35 UTC (permalink / raw)
  To: Daniel Vicarel; +Cc: Chris Packham, GIT

Daniel Vicarel <shundra8820@gmail.com> writes:

> Thanks for the input, all.
>
> Junio C Hamano <gitster@pobox.com> writes:
>> perhaps the doc update would be the quickest one that offers the most to learn from
>
> Sounds good! Now by "doc update" do you mean updating docs in the
> Documentation/ folder, or adding a warning to the CLI output of `git
> merge --continue`?

The former.  The current text says "... you can conclude the merge
by running `git merge --continue`" without giving a clue that this
is another way to say "git commit" that is longer to type.

The way it rejects extra arguments happens to work as a safety valve
that is not very end-user friendly; as you found out, it rejects
options and arguments (like pathspec).  So "--continue" is more than
a mere synonym to "git commit".

> Junio C Hamano <gitster@pobox.com> writes:
>> coming up with a sensible list of allowed options and arguments [to `git merge --continue`] would be quite hard.
>
> Chris Packham <judge.packham@gmail.com> writes:
>> I think it'd be a good idea to allow [--no-edit on `git merge --continue`] as long as it's the only other option allowed with --continue.
>
> Based on these two pieces of feedback, it sounds like adding _just_
> the `--no-edit` option at this point to `git merge --continue` is
> worthwhile, and hopefully approachable for a newb. For now I'll put a
> pin in it though, and focus on the documentation task above.

Well, I don't know about Chris, but I didn't mean to suggest that by
saying that deciding which ones to allow and which ones to reject is
hard.  Knowing that there are other options that deserve the same
attention as `--no-edit` to be supported now makes a patch to only
add support for `--no-edit` an incomplete one.  If we need to add
support for more in the future, at least the mechanism used to add
the first one should be something we can reuse in the future for
these other ones.

The way "git commit" is internally invoked from "git merge --continue"
happens to work with the current "we only pass no arguments, and we
exit once the command is done" usage, but it fundamentally is wrong.
No cmd_foo() functions should be called from anything but the
run_builtin() function in git.c, as they are not prepared to be
called twice, and they are not prepared to be called in an
environment where other things (like reading configuration files)
have already happened.  If we were to extend what is passed when
"git merge --continue" calls "git commit", we should first clean up
the (ab)use of cmd_commit() call from the code path, before adding
new features.

So, no, I do not think it is a welcome change to just allow passing
"--no-edit" in a way that is "approachable for a newb".

Thanks.



^ permalink raw reply	[flat|nested] 12+ messages in thread

* Re: Why does "merge --continue" expect no arguments?
  2021-12-21 17:13 ` Junio C Hamano
  2021-12-21 17:51   ` Daniel Vicarel
  2021-12-21 17:57   ` Philip Oakley
@ 2021-12-24 17:08   ` Ævar Arnfjörð Bjarmason
  2021-12-25  2:01     ` Junio C Hamano
  2 siblings, 1 reply; 12+ messages in thread
From: Ævar Arnfjörð Bjarmason @ 2021-12-24 17:08 UTC (permalink / raw)
  To: Junio C Hamano; +Cc: Daniel Vicarel, git


On Tue, Dec 21 2021, Junio C Hamano wrote:

> 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".

But it's not:

    $ git add foo
    $ git commit -v
    hint: Waiting for your editor to close the file.[...]
    ^C
    $ git merge --continue
    fatal: There is no merge in progress (MERGE_HEAD missing).

FWIW I prefer and use it for that reason, i.e. it's useful for scripting
to use these "stateful" commands when we're in some sort of rebase/merge
"sequence" since it's an extra layer of sanity checking.

^ permalink raw reply	[flat|nested] 12+ messages in thread

* Re: Why does "merge --continue" expect no arguments?
  2021-12-24 17:08   ` Ævar Arnfjörð Bjarmason
@ 2021-12-25  2:01     ` Junio C Hamano
  2021-12-26 23:31       ` Ævar Arnfjörð Bjarmason
  0 siblings, 1 reply; 12+ messages in thread
From: Junio C Hamano @ 2021-12-25  2:01 UTC (permalink / raw)
  To: Ævar Arnfjörð Bjarmason; +Cc: Daniel Vicarel, git

Ævar Arnfjörð Bjarmason <avarab@gmail.com> writes:

> On Tue, Dec 21 2021, Junio C Hamano wrote:
>
>> 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".
>
> But it's not:
>
>     $ git add foo
>     $ git commit -v
>     hint: Waiting for your editor to close the file.[...]
>     ^C
>     $ git merge --continue
>     fatal: There is no merge in progress (MERGE_HEAD missing).
>
> FWIW I prefer and use it for that reason, i.e. it's useful for scripting
> to use these "stateful" commands when we're in some sort of rebase/merge
> "sequence" since it's an extra layer of sanity checking.

There is no additional safety afforded by that, though.  There is no
reason why one would even try to say "merge --continue" without
doing any merge to begin with.

The "merge --continue" not taking any pathspec is a bit of safety,
but even there, "commit" already has its own safety to reject
pathspec when it notices that it is concluding a conflicted "merge",
so "merge --continue" is not necessary for additional safety there,
either.




^ permalink raw reply	[flat|nested] 12+ messages in thread

* Re: Why does "merge --continue" expect no arguments?
  2021-12-25  2:01     ` Junio C Hamano
@ 2021-12-26 23:31       ` Ævar Arnfjörð Bjarmason
  2021-12-27 19:29         ` Junio C Hamano
  0 siblings, 1 reply; 12+ messages in thread
From: Ævar Arnfjörð Bjarmason @ 2021-12-26 23:31 UTC (permalink / raw)
  To: Junio C Hamano; +Cc: Daniel Vicarel, git


On Fri, Dec 24 2021, Junio C Hamano wrote:

> Ævar Arnfjörð Bjarmason <avarab@gmail.com> writes:
>
>> On Tue, Dec 21 2021, Junio C Hamano wrote:
>>
>>> 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".
>>
>> But it's not:
>>
>>     $ git add foo
>>     $ git commit -v
>>     hint: Waiting for your editor to close the file.[...]
>>     ^C
>>     $ git merge --continue
>>     fatal: There is no merge in progress (MERGE_HEAD missing).
>>
>> FWIW I prefer and use it for that reason, i.e. it's useful for scripting
>> to use these "stateful" commands when we're in some sort of rebase/merge
>> "sequence" since it's an extra layer of sanity checking.
>
> There is no additional safety afforded by that, though.  There is no
> reason why one would even try to say "merge --continue" without
> doing any merge to begin with.
>
> The "merge --continue" not taking any pathspec is a bit of safety,
> but even there, "commit" already has its own safety to reject
> pathspec when it notices that it is concluding a conflicted "merge",
> so "merge --continue" is not necessary for additional safety there,
> either.

The reason would be that you're confused about what state you're in.

I've had that a few times, so I prefer it over "git commit", so I daresy
someone less experienced in using git could and would benefit from it as
well.

Usually because my "__git_ps1" and a subsequent "git status" shows one
state, so I'll want to continue the merge, but forgot that I did so in
another terminal tab already, and the real state of the repository might
have moved on to the index being prepared for a non-merge commit.

For "rebase --continue" we change the reflog entry from "rebase (pick)"
to "rebase (continue)". Any reason we wouldn't do the same for "merge
--continue"?:

diff --git a/builtin/merge.c b/builtin/merge.c
index 5f0476b0b76..51ef8ca36d0 100644
--- a/builtin/merge.c
+++ b/builtin/merge.c
@@ -1358,6 +1358,10 @@ int cmd_merge(int argc, const char **argv, const char *prefix)
 		if (!file_exists(git_path_merge_head(the_repository)))
 			die(_("There is no merge in progress (MERGE_HEAD missing)."));
 
+		strbuf_addstr(&buf, "merge (continue)");
+		setenv("GIT_REFLOG_ACTION", buf.buf, 0);
+		strbuf_reset(&buf);
+
 		/* Invoke 'git commit' */
 		ret = cmd_commit(nargc, nargv, prefix);
 		goto done;
diff --git a/t/t7600-merge.sh b/t/t7600-merge.sh
index c773e30b3fa..7a180f571b7 100755
--- a/t/t7600-merge.sh
+++ b/t/t7600-merge.sh
@@ -772,6 +772,8 @@ test_expect_success 'completed merge (git merge --continue) with --no-commit and
 	git stash show -p MERGE_AUTOSTASH >actual &&
 	test_cmp expect actual &&
 	git merge --continue 2>err &&
+	git reflog -1 >reflog &&
+	grep -F "merge (continue)" reflog &&
 	test_i18ngrep "Applied autostash." err &&
 	git show HEAD:file >merge-result &&
 	test_cmp result.1-5 merge-result &&

^ permalink raw reply related	[flat|nested] 12+ messages in thread

* Re: Why does "merge --continue" expect no arguments?
  2021-12-26 23:31       ` Ævar Arnfjörð Bjarmason
@ 2021-12-27 19:29         ` Junio C Hamano
  0 siblings, 0 replies; 12+ messages in thread
From: Junio C Hamano @ 2021-12-27 19:29 UTC (permalink / raw)
  To: Ævar Arnfjörð Bjarmason; +Cc: Daniel Vicarel, git

Ævar Arnfjörð Bjarmason <avarab@gmail.com> writes:

>>>     $ git merge --continue
>>>     fatal: There is no merge in progress (MERGE_HEAD missing).
>>>
>>> FWIW I prefer and use it for that reason, i.e. it's useful for scripting
>>> to use these "stateful" commands when we're in some sort of rebase/merge
>>> "sequence" since it's an extra layer of sanity checking.
>>
>> There is no additional safety afforded by that, though.  There is no
>> reason why one would even try to say "merge --continue" without
>> doing any merge to begin with.
>>
>> The "merge --continue" not taking any pathspec is a bit of safety,
>> but even there, "commit" already has its own safety to reject
>> pathspec when it notices that it is concluding a conflicted "merge",
>> so "merge --continue" is not necessary for additional safety there,
>> either.
>
> The reason would be that you're confused about what state you're in.
>
> I've had that a few times, so I prefer it over "git commit", so I daresy
> someone less experienced in using git could and would benefit from it as
> well.

One can be lost and think that one is in the middle of "git merge"
when in reality there is no merge going on.  Or one can be lost and
confused the other way around, i.e. one thinks one is about to
finish the work one has been doing and conclude in a single parent
commit when in reality that one has done all that is necessary to
whip the working tree and the index into a state good enough to
record as a commit object.

In the former case, saying "git merge --continue", instead of "git
commit" may STOP oneself from proceeding, but then what?

Step back and think the other confusion first.  Saying "git commit",
instead of "git merge --continue", would allow one to record the
merge commit.  It opens an editor, its first line of the log message
would say "Merge blah into bar", the comment section tells you that
you are committing a merge.  It even prevents one from making a
partial commit with "git commit <pathspec>" or screw up the state
with "git commit --amend".  It is totally safe.

Now back to the former case.  You thought your working tree contents
and the index was good enough shape to say "git merge --continue",
but the command refuses because you were not merging.  I have a
suspicion that the message I am responding is a straw-man not worth
I should spend more time on, and if you are truly lost you would
either (1) look at the command line prompt or (2) run "git status"
to re-orient yourself before doing anything drastic like running the
"git merge --continue" command, but hypothetically, if you are lost
between merge and commit yet you are confident enough that your
working tree state and the index is worth recording in a commit
anyway, after a mistaken "git merge --continue" stops you from doing
so, I expect that you would "git commit" to record that tree into a
commit anyway, no?

So, I do agree there would be cases where a user is lost and does
not know what state the working tree s/he just came back to is in,
but "git merge --continue" is a mechanism that gives great help to
such a user.  "git status" may well be such a command, but "git
merge --continue" is not, and training users to use the latter
certainly is a wrong direction to go in.

By the way, you are wasting your time by repeating what you already
said and given an answer that the line of reasoning does not make
much sense.  Unless your goal is to be the one that sends the last
message to a discussion thread, that is.  You can respond to this
message without anything new and I promise that I won't repeat what
has been said already, in such a case.  So you'll be the last one to
utter in this thread then ;-)

You can share a new perspective, of course, in which case I may say
"Light! thanks".





^ permalink raw reply	[flat|nested] 12+ messages in thread

end of thread, other threads:[~2021-12-27 19:29 UTC | newest]

Thread overview: 12+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-12-21 14:50 Why does "merge --continue" expect no arguments? Daniel Vicarel
2021-12-21 17:13 ` Junio C Hamano
2021-12-21 17:51   ` Daniel Vicarel
2021-12-21 17:54     ` Daniel Vicarel
2021-12-22  6:20     ` Junio C Hamano
2021-12-21 17:57   ` Philip Oakley
2021-12-24 17:08   ` Ævar Arnfjörð Bjarmason
2021-12-25  2:01     ` Junio C Hamano
2021-12-26 23:31       ` Ævar Arnfjörð Bjarmason
2021-12-27 19:29         ` Junio C Hamano
     [not found] ` <CAFOYHZC0r35mfOVUExHsBP5=URKFAt_wDTZ51pTc=XkXyogqKQ@mail.gmail.com>
2021-12-23  6:07   ` Daniel Vicarel
2021-12-23 18:35     ` Junio C Hamano

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.