git.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Junio C Hamano <gitster@pobox.com>
To: Johannes Sixt <j6t@kdbg.org>
Cc: Phillip Wood <phillip.wood@dunelm.org.uk>,
	 Git Mailing List <git@vger.kernel.org>
Subject: Re: [PATCH] rebase -i: permit 'drop' of a merge commit
Date: Wed, 06 Aug 2025 14:04:31 -0700	[thread overview]
Message-ID: <xmqqjz3gtb4w.fsf@gitster.g> (raw)
In-Reply-To: <37f6e34c-91aa-4e55-88e1-019d2e042df3@kdbg.org> (Johannes Sixt's message of "Wed, 6 Aug 2025 19:38:35 +0200")

Johannes Sixt <j6t@kdbg.org> writes:

> 4c063c82e9 (rebase -i: improve error message when picking merge,
> 2024-05-30) added advice texts for cases when a merge commit is
> passed as argument of sequencer command that cannot operate with
> a merge commit. However, it forgot about the 'drop' command, so
> that in this case the BUG() in the default branch is reached.
>
> Handle 'drop' like 'merge', i.e., permit it without a message.
>
> Signed-off-by: Johannes Sixt <j6t@kdbg.org>
> ---
>  sequencer.c                   | 1 +
>  t/t3404-rebase-interactive.sh | 1 +
>  2 files changed, 2 insertions(+)

Thanks.  Now I understand why some people are sometimes tempted to
omit the default arm in switch() and allow compilers complain when
explicit case arms are not exhaustive.  I am not saying we should do
so, and I am not convinced that it is a good idea (there are cases
you cannot afford to be exhausitive, yet the cases your particular
switch must care about are multiple to make an if/else if cascade
impractical).  But this is one of the case it might make sense.

> diff --git a/sequencer.c b/sequencer.c
> index aaf2e4df64..9ae40a91b2 100644
> --- a/sequencer.c
> +++ b/sequencer.c
> @@ -2720,8 +2720,9 @@ static int check_merge_commit_insn(enum todo_command command)
>  	case TODO_SQUASH:
>  		return error(_("cannot squash merge commit into another commit"));
>  
>  	case TODO_MERGE:
> +	case TODO_DROP:
>  		return 0;
>  
>  	default:
>  		BUG("unexpected todo_command");
> diff --git a/t/t3404-rebase-interactive.sh b/t/t3404-rebase-interactive.sh
> index 6bac217ed3..34d6ad0770 100755
> --- a/t/t3404-rebase-interactive.sh
> +++ b/t/t3404-rebase-interactive.sh
> @@ -2262,8 +2262,9 @@ rebase_setup_and_clean () {
>  	reword $oid
>  	edit $oid
>  	fixup $oid
>  	squash $oid
> +	drop $oid # acceptable, no advice
>  	EOF
>  	(
>  		set_replace_editor todo &&
>  		test_must_fail git rebase -i HEAD 2>actual

  reply	other threads:[~2025-08-06 21:04 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-08-06 17:38 [PATCH] rebase -i: permit 'drop' of a merge commit Johannes Sixt
2025-08-06 21:04 ` Junio C Hamano [this message]
2025-08-07 13:50   ` Phillip Wood
2025-08-07 13:39 ` Phillip Wood

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=xmqqjz3gtb4w.fsf@gitster.g \
    --to=gitster@pobox.com \
    --cc=git@vger.kernel.org \
    --cc=j6t@kdbg.org \
    --cc=phillip.wood@dunelm.org.uk \
    /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).