git.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Phillip Wood <phillip.wood123@gmail.com>
To: Junio C Hamano <gitster@pobox.com>,
	Phillip Wood via GitGitGadget <gitgitgadget@gmail.com>
Cc: git@vger.kernel.org, "Stefan Haller" <lists@haller-berlin.de>,
	"Johannes Schindelin" <Johannes.Schindelin@gmx.de>,
	"Patrick Steinhardt" <ps@pks.im>,
	"Rubén Justo" <rjusto@gmail.com>,
	"Phillip Wood" <phillip.wood@dunelm.org.uk>
Subject: Re: [PATCH v2 2/2] rebase -i: improve error message when picking merge
Date: Tue, 9 Apr 2024 16:04:33 +0100	[thread overview]
Message-ID: <1b74f6f9-f4b9-4909-82b3-26f19b7a1347@gmail.com> (raw)
In-Reply-To: <xmqqle5n7ajt.fsf@gitster.g>

Hi Junio

On 08/04/2024 23:29, Junio C Hamano wrote:
> "Phillip Wood via GitGitGadget" <gitgitgadget@gmail.com> writes:
>> +	case TODO_EDIT:
>> +		return error(_("'%s' does not accept merge commits, "
>> +			       "please use '%s' followed by '%s'"),
>> +			     todo_command_info[command].str,
>> +			     "merge -C", "break");
> 
> OK.  And when hitting the "break", they know that they are supposed
> to say "git commit --amend" and then "git rebase --continue"?

Yes. I guess we could add a hint to that effect if you think its worth it.

>>   	item->commit = lookup_commit_reference(r, &commit_oid);
>> -	return item->commit ? 0 : -1;
>> +	if (!item->commit)
>> +		return -1;
>> +	if (is_rebase_i(opts) && item->command != TODO_MERGE &&
>> +	    item->commit->parents && item->commit->parents->next)
>> +		return error_merge_commit(item->command);
> 
> This is good for now, but we may see command other than TODO_MERGE
> learn how to handle a merge commit, and when that happens, I wonder
> what we want to do here.  One thought is to do this:
> 
> 	if (is_rebase_i(opts) && is_merge_commit(item->commit))
>          	return error_merge_commit(item);
> 
> and teach error_merge_commit() to silently return 0 on TODO_MERGE.
> Other commands, when they learn how to deal with a merge commit,
> will then update their entries in error_merge_commit().
f
It feels funny to call error_merge_commit() for a command that we know 
supports merges but I can see that would make it easier to extend in the 
future.

> Would we want to customize the message from error_merge_commit() to
> make it closer to cut-and-paste ready?  For that, something like
> 
> 	int error_merge_commit(struct todo_item *item)
> 	{
> 		switch (item->command) {
> 		case TODO_PICK:
> 			return error(_("'%s'" is bad, plase use "
> 				       '%s %s'"),
> 				todo_command_info[item->command].str,
> 				"merge -C",
> 				oid_to_hex(item->commit->oid));
> 		...
> 		}
> 	}
> 
> might go in a more friendly way.

If we want something the user can cut and paste then we would need to 
suggest a second parent for the merge. We cannot just use the existing 
parent as it may be rebased which means tracking all the commits we see 
while parsing the list. If the second parent is rebased we need to make 
sure the user labels it so we can use that label here. For that reason 
(and the fact that I don't think can we really tell what the user was 
hoping to achieve) I think the best we can do is point the user in the 
direction of the "merge" command even though that leaves them to figure 
out what to do with that command.

Best Wishes

Phillip


  parent reply	other threads:[~2024-04-09 15:04 UTC|newest]

Thread overview: 26+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-02-26 10:58 [PATCH] rebase -i: improve error message when picking merge Phillip Wood via GitGitGadget
2024-04-03 13:42 ` phillip.wood123
2024-04-04  6:08   ` Patrick Steinhardt
2024-04-04  6:08 ` Patrick Steinhardt
2024-04-04 15:29   ` phillip.wood123
2024-04-04 19:44 ` Rubén Justo
2024-04-05  9:30   ` phillip.wood123
2024-04-06 14:24     ` Rubén Justo
2024-04-07 13:55       ` phillip.wood123
2024-04-08 14:16 ` [PATCH v2 0/2] " Phillip Wood via GitGitGadget
2024-04-08 14:16   ` [PATCH v2 1/2] rebase -i: pass struct replay_opts to parse_insn_line() Phillip Wood via GitGitGadget
2024-04-09  4:03     ` Patrick Steinhardt
2024-04-08 14:16   ` [PATCH v2 2/2] rebase -i: improve error message when picking merge Phillip Wood via GitGitGadget
2024-04-08 22:29     ` Junio C Hamano
2024-04-09  4:03       ` Patrick Steinhardt
2024-04-09  5:08         ` Junio C Hamano
2024-04-09  6:04           ` Patrick Steinhardt
2024-04-09 15:04       ` Phillip Wood [this message]
2024-04-09 19:56         ` Junio C Hamano
2024-04-12 13:24           ` Phillip Wood
2024-05-30 13:43   ` [PATCH v3 0/2] " Phillip Wood via GitGitGadget
2024-05-30 13:43     ` [PATCH v3 1/2] rebase -i: pass struct replay_opts to parse_insn_line() Phillip Wood via GitGitGadget
2024-05-30 13:43     ` [PATCH v3 2/2] rebase -i: improve error message when picking merge Phillip Wood via GitGitGadget
2024-05-30 17:09     ` [PATCH v3 0/2] " Junio C Hamano
2024-06-03  9:22       ` Phillip Wood
2024-06-03 15:42         ` Junio C Hamano

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1b74f6f9-f4b9-4909-82b3-26f19b7a1347@gmail.com \
    --to=phillip.wood123@gmail.com \
    --cc=Johannes.Schindelin@gmx.de \
    --cc=git@vger.kernel.org \
    --cc=gitgitgadget@gmail.com \
    --cc=gitster@pobox.com \
    --cc=lists@haller-berlin.de \
    --cc=phillip.wood@dunelm.org.uk \
    --cc=ps@pks.im \
    --cc=rjusto@gmail.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).