Commit

a3837282fe8415620f1da7e333643d734b03fe07

commit: reword the empty-commit rebase amend error

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 amending is refused, with:

    You are in the middle of a rebase -- cannot amend.

That message would suggest that amending is not allowed during an 'edit'
or 'break' stop, which is misleading, plus it lacks the specificity that
might help the user know why their particular case is a problem: the
commit they intended to amend became empty and was dropped, so amending
would affect the wrong commit.  Reword the error accordingly.

Signed-off-by: Elijah Newren <newren@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>

Elijah Newren <newren@gmail.com> · 2026-09-01 22:24 UTC · committed by Junio C Hamano

Browse files
2 files changed, +2 −2
modified builtin/commit.c
@@ -1332,7 +1332,7 @@ static int parse_and_validate_options(int argc, const char *argv[],
1332 1332 else if (is_from_cherry_pick(whence))
1333 1333 die(_("You are in the middle of a cherry-pick -- cannot amend."));
1334 1334 else if (is_from_rebase_now_empty(whence))
1335 - die(_("You are in the middle of a rebase -- cannot amend."));
1335 + die(_("The now-empty commit has been dropped -- cannot amend."));
1336 1336 }
1337 1337 if (fixup_message && squash_message)
1338 1338 die(_("options '%s' and '%s' cannot be used together"), "--squash", "--fixup");
modified t/t3404-rebase-interactive.sh
@@ -1851,7 +1851,7 @@ test_expect_success 'correct error message for commit --amend after empty pick'
1851 1851 ) &&
1852 1852 echo x>file1 &&
1853 1853 test_must_fail git commit -a --amend 2>err &&
1854 - test_grep "middle of a rebase -- cannot amend." err
1854 + test_grep "now-empty commit has been dropped -- cannot amend." err
1855 1855 '
1856 1856
1857 1857 test_expect_success 'todo has correct onto hash' '