git/list[1] front-page[2] threads[3] people[4] search[5] about
 

Re: [PATCH] commit: refuse to amend during conflict resolution

From
Junio C Hamano <gitster@pobox.com>
Date
Aug 26, 2026, 16:22 UTC
Message-ID
<xmqqzey8j1gt.fsf@gitster.g>
In-Reply-To
<pull.2389.git.git.1787721681893.gitgitgadget@gmail.com>
"Elijah Newren via GitGitGadget" <gitgitgadget@gmail.com> writes:
Show 8 quoted lines
> ...  However, with the merge backend of rebase we have to
> be more careful, since it powers interactive rebases and
>   - the interactive machinery internally uses `git commit --amend` for
>     `squash` and `reword` directives
>   - users are expected to `git commit --amend` after hitting an `edit`
>     or `break` directive
> So, we need to be careful with rebase to only reject amending when doing
> conflict resolution.
True.

In addition, in any and all of these scenarios that lets the user deal with conflicts in his or her working tree files and record the result of conflict resolution in a commit, we should reject not only "git commit --amend" but also "git commit <paths>", shouldn't we?

It may probably be better done in a separate topic, as the guiding principle is slightly different (i.e., "recording the conflict resolution is about recording the state on top of the current HEAD and never about updating the state recorded in the current HEAD" is the theme of the current topic. "recording the conflict resolution is always about the entire tree" is the other topic), so we may want to leave a #leftoverbits marker here.

Show 20 quoted lines
> A few files under the rebase-merge/ directory provide us the necessary
> information:
>
>   - stopped-sha is written only when the rebase stops and hands control
>     back to the user, so its presence marks a genuine stop -- as opposed
>     to the sequencer's own internal `git commit --amend` while applying
>     a squash, fixup, or reword, during which no stopped-sha exists.
>
>   - amend is written only when the rebase stops with HEAD already
>     pointing at the commit the user is meant to amend: a clean `edit`,
>     or a fast-forward `reword`.  Its absence at a stop therefore means
>     the commit did not apply, so HEAD is the previously-applied commit
>     rather than the one being rebased -- exactly the case we refuse.
>
> So for the merge backend we die when stopped-sha exists and amend does
> not.  This covers a plain conflicted pick as well as a conflicted `edit`
> (both leave HEAD on the previously-applied commit), while still allowing
> a clean `edit` or `reword` stop and a `break` stop (no stopped-sha).
> stopped-sha is unlinked at the start of the resume loop, so a resumed
> squash's internal amend is unaffected.
That is a sound reasoning.  Nice.
> Signed-off-by: Elijah Newren <newren@gmail.com>
> ---
Previous: Elijah NewrenNext: Elijah Newren
Message 4 of 43 in “commit: refuse to amend during conflict resolution”
  1. commit: refuse to amend during conflict resolutionElijah Newren via GitGitGadget, Aug 26, 2026
  2. Phillip WoodAug 26, 2026
  3. Elijah NewrenAug 27, 2026
  4. Junio C HamanoAug 26, 2026
  5. Elijah NewrenAug 27, 2026
  6. Junio C HamanoAug 26, 2026
  7. Elijah NewrenAug 27, 2026
  8. 0/3 commit: refuse to amend during conflict resolutionElijah Newren via GitGitGadget, Aug 27, 2026
  9. 1/3 commit: reword the empty-commit rebase errorsElijah Newren via GitGitGadget, Aug 27, 2026
  10. Phillip WoodAug 27, 2026
  11. Junio C HamanoAug 27, 2026
  12. Elijah NewrenAug 28, 2026
  13. Junio C HamanoAug 27, 2026
  14. Junio C HamanoAug 27, 2026
  15. Elijah NewrenAug 28, 2026
  16. 2/3 commit: refuse to amend during conflict resolutionElijah Newren via GitGitGadget, Aug 27, 2026
  17. Phillip WoodAug 27, 2026
  18. 3/3 commit: refuse partial commits during conflict resolutionElijah Newren via GitGitGadget, Aug 27, 2026
  19. Phillip WoodAug 27, 2026
  20. Phillip WoodAug 27, 2026
  21. Elijah NewrenAug 27, 2026
  22. 0/5 commit: refuse to amend during conflict resolutionElijah Newren via GitGitGadget, Aug 28, 2026
  23. 1/5 commit: clarify FROM_REBASE_PICK and is_from_rebase() namesElijah Newren via GitGitGadget, Aug 28, 2026
  24. Junio C HamanoAug 28, 2026
  25. Elijah NewrenAug 28, 2026
  26. 2/5 commit: allow a partial commit when a rebase pick becomes emptyElijah Newren via GitGitGadget, Aug 28, 2026
  27. Junio C HamanoAug 28, 2026
  28. 3/5 commit: reword the empty-commit rebase amend errorElijah Newren via GitGitGadget, Aug 28, 2026
  29. Junio C HamanoAug 28, 2026
  30. 4/5 commit: refuse to amend during conflict resolutionElijah Newren via GitGitGadget, Aug 28, 2026
  31. 5/5 commit: refuse partial commits during conflict resolutionElijah Newren via GitGitGadget, Aug 28, 2026
  32. Junio C HamanoAug 28, 2026
  33. 0/5 commit: refuse to amend during conflict resolutionElijah Newren via GitGitGadget, Sep 1, 2026
  34. 1/5 commit: clarify FROM_REBASE_PICK and is_from_rebase() namesElijah Newren via GitGitGadget, Sep 1, 2026
  35. Phillip WoodSep 2, 2026
  36. 2/5 commit: allow a partial commit when a rebase pick becomes emptyElijah Newren via GitGitGadget, Sep 1, 2026
  37. Phillip WoodSep 2, 2026
  38. 3/5 commit: reword the empty-commit rebase amend errorElijah Newren via GitGitGadget, Sep 1, 2026
  39. Phillip WoodSep 2, 2026
  40. 4/5 commit: refuse to amend during conflict resolutionElijah Newren via GitGitGadget, Sep 1, 2026
  41. Phillip WoodSep 2, 2026
  42. 5/5 commit: refuse partial commits during conflict resolutionElijah Newren via GitGitGadget, Sep 1, 2026
  43. Phillip WoodSep 2, 2026

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.