Re: [PATCH v2 1/3] commit: reword the empty-commit rebase errors
- From
- Phillip Wood <phillip.wood123@gmail.com>
- Date
- Aug 27, 2026, 15:19 UTC
- Message-ID
- <dec05fd6-b99c-4a71-b80e-24e7d6de4b62@gmail.com>
- In-Reply-To
- <65c48ed3cb638cf0be18a3aa6d86d4c4f2cf01a2.1787792534.git.gitgitgadget@gmail.com>
Hi Elijah
On 27/08/2026 02:02, Elijah Newren via GitGitGadget wrote:
Show 31 quoted lines
> From: Elijah Newren <newren@gmail.com>
>
> When a rebase applies a commit that becomes empty, it stops and asks the
> user to decide whether to keep it or drop it. HEAD still points at the
> previously-applied commit at that point, so either amending or creating
> a partial commit is refused, with one of the following messages:
>
> You are in the middle of a rebase -- cannot amend.
> cannot do a partial commit during a rebase.
>
> Neither message hints that the real problem is a commit that became
> empty, and "during a rebase" is overly broad besides -- amending and
> partial commits are fine at an `edit` or `break` stop. Reword both to
> describe the actual situation.
>
> Signed-off-by: Elijah Newren <newren@gmail.com>
> ---
> builtin/commit.c | 4 ++--
> t/t3404-rebase-interactive.sh | 4 ++--
> 2 files changed, 4 insertions(+), 4 deletions(-)
>
> diff --git a/builtin/commit.c b/builtin/commit.c
> index 28f6174503..0d908d72bb 100644
> --- a/builtin/commit.c
> +++ b/builtin/commit.c
> @@ -521,7 +521,7 @@ static const char *prepare_index(const char **argv, const char *prefix,
> else if (is_from_cherry_pick(whence))
> die(_("cannot do a partial commit during a cherry-pick."));
> else if (is_from_rebase(whence))
> - die(_("cannot do a partial commit during a rebase."));
> + die(_("cannot do a partial commit while resolving a commit that became empty."));"while committing a commit that became empty" would be clearer to me, but I what you have is definitely an improvement on the existing message.
Thanks
Phillip
Show 34 quoted lines
> }
>
> if (list_paths(&partial, !current_head ? NULL : "HEAD", &pathspec))
> @@ -1334,7 +1334,7 @@ static int parse_and_validate_options(int argc, const char *argv[],
> else if (is_from_cherry_pick(whence))
> die(_("You are in the middle of a cherry-pick -- cannot amend."));
> else if (whence == FROM_REBASE_PICK)
> - die(_("You are in the middle of a rebase -- cannot amend."));
> + die(_("You are resolving a commit that became empty -- cannot amend."));
> }
> if (fixup_message && squash_message)
> die(_("options '%s' and '%s' cannot be used together"), "--squash", "--fixup");
> diff --git a/t/t3404-rebase-interactive.sh b/t/t3404-rebase-interactive.sh
> index ff11abb2f2..1e78dbfd90 100755
> --- a/t/t3404-rebase-interactive.sh
> +++ b/t/t3404-rebase-interactive.sh
> @@ -1868,7 +1868,7 @@ test_expect_success 'correct error message for partial commit after empty pick'
> ) &&
> echo x >file1 &&
> test_must_fail git commit file1 2>err &&
> - test_grep "cannot do a partial commit during a rebase." err
> + test_grep "cannot do a partial commit while resolving a commit that became empty." err
> '
>
> test_expect_success 'correct error message for commit --amend after empty pick' '
> @@ -1881,7 +1881,7 @@ test_expect_success 'correct error message for commit --amend after empty pick'
> ) &&
> echo x>file1 &&
> test_must_fail git commit -a --amend 2>err &&
> - test_grep "middle of a rebase -- cannot amend." err
> + test_grep "resolving a commit that became empty -- cannot amend." err
> '
>
> test_expect_success 'todo has correct onto hash' '