* [PATCH] rebase -i: permit 'drop' of a merge commit
@ 2025-08-06 17:38 Johannes Sixt
2025-08-06 21:04 ` Junio C Hamano
2025-08-07 13:39 ` Phillip Wood
0 siblings, 2 replies; 4+ messages in thread
From: Johannes Sixt @ 2025-08-06 17:38 UTC (permalink / raw)
To: Phillip Wood; +Cc: Git Mailing List
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(+)
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
--
2.50.1.837.g8c5950ae16
^ permalink raw reply related [flat|nested] 4+ messages in thread
* Re: [PATCH] rebase -i: permit 'drop' of a merge commit
2025-08-06 17:38 [PATCH] rebase -i: permit 'drop' of a merge commit Johannes Sixt
@ 2025-08-06 21:04 ` Junio C Hamano
2025-08-07 13:50 ` Phillip Wood
2025-08-07 13:39 ` Phillip Wood
1 sibling, 1 reply; 4+ messages in thread
From: Junio C Hamano @ 2025-08-06 21:04 UTC (permalink / raw)
To: Johannes Sixt; +Cc: Phillip Wood, Git Mailing List
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
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH] rebase -i: permit 'drop' of a merge commit
2025-08-06 17:38 [PATCH] rebase -i: permit 'drop' of a merge commit Johannes Sixt
2025-08-06 21:04 ` Junio C Hamano
@ 2025-08-07 13:39 ` Phillip Wood
1 sibling, 0 replies; 4+ messages in thread
From: Phillip Wood @ 2025-08-07 13:39 UTC (permalink / raw)
To: Johannes Sixt, Phillip Wood; +Cc: Git Mailing List
Hi Johannes
On 06/08/2025 18:38, Johannes Sixt wrote:
> 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.
Thanks for fixing this and also for taking the time to extend the
regression test.
Phillip
> Signed-off-by: Johannes Sixt <j6t@kdbg.org>
> ---
> sequencer.c | 1 +
> t/t3404-rebase-interactive.sh | 1 +
> 2 files changed, 2 insertions(+)
>
> 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
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH] rebase -i: permit 'drop' of a merge commit
2025-08-06 21:04 ` Junio C Hamano
@ 2025-08-07 13:50 ` Phillip Wood
0 siblings, 0 replies; 4+ messages in thread
From: Phillip Wood @ 2025-08-07 13:50 UTC (permalink / raw)
To: Junio C Hamano, Johannes Sixt; +Cc: Phillip Wood, Git Mailing List
On 06/08/2025 22:04, Junio C Hamano wrote:
> Johannes Sixt <j6t@kdbg.org> writes:
>
> 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.
I think there are definitely cases like this where it makes sense to
require the case statements to be exhaustive. Looking at the
documentation for -Wswitch [1] which is enabled by -Wall it only issues
a warning when there is no default arm and the case statements are
non-exhaustive. So I think we could start relying on that just by
deleting the default arms where we think it makes sense for the case
statements to be exhaustive. I've previously worked on a code base that
enabled -Wswitch-enum which requires the case statements to be
exhaustive even if there is a default arm and that was a pain in the neck.
Thanks
Phillip
[1]
https://gcc.gnu.org/onlinedocs/gcc-15.1.0/gcc/Warning-Options.html#index-Wswitch
>> 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
>
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2025-08-07 13:50 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-08-06 17:38 [PATCH] rebase -i: permit 'drop' of a merge commit Johannes Sixt
2025-08-06 21:04 ` Junio C Hamano
2025-08-07 13:50 ` Phillip Wood
2025-08-07 13:39 ` Phillip Wood
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).