From: Junio C Hamano <gitster@pobox.com>
To: "Elijah Newren via GitGitGadget" <gitgitgadget@gmail.com>
Cc: git@vger.kernel.org, Phillip Wood <phillip.wood@dunelm.org.uk>,
Elijah Newren <newren@gmail.com>
Subject: Re: [PATCH] commit: refuse to amend during conflict resolution
Date: Wed, 26 Aug 2026 09:22:42 -0700 [thread overview]
Message-ID: <xmqqzey8j1gt.fsf@gitster.g> (raw)
In-Reply-To: <pull.2389.git.git.1787721681893.gitgitgadget@gmail.com> (Elijah Newren via GitGitGadget's message of "Wed, 26 Aug 2026 05:21:21 +0000")
"Elijah Newren via GitGitGadget" <gitgitgadget@gmail.com> writes:
> ... 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.
> 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>
> ---
next prev parent reply other threads:[~2026-08-26 16:22 UTC|newest]
Thread overview: 32+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-08-26 5:21 [PATCH] commit: refuse to amend during conflict resolution Elijah Newren via GitGitGadget
2026-08-26 13:56 ` Phillip Wood
2026-08-27 0:21 ` Elijah Newren
2026-08-26 16:22 ` Junio C Hamano [this message]
2026-08-27 0:23 ` Elijah Newren
2026-08-26 16:39 ` Junio C Hamano
2026-08-27 0:24 ` Elijah Newren
2026-08-27 1:02 ` [PATCH v2 0/3] " Elijah Newren via GitGitGadget
2026-08-27 1:02 ` [PATCH v2 1/3] commit: reword the empty-commit rebase errors Elijah Newren via GitGitGadget
2026-08-27 15:19 ` Phillip Wood
2026-08-27 16:54 ` Junio C Hamano
2026-08-28 7:38 ` Elijah Newren
2026-08-27 16:35 ` Junio C Hamano
2026-08-27 16:52 ` Junio C Hamano
2026-08-28 7:38 ` Elijah Newren
2026-08-27 1:02 ` [PATCH v2 2/3] commit: refuse to amend during conflict resolution Elijah Newren via GitGitGadget
2026-08-27 15:19 ` Phillip Wood
2026-08-27 1:02 ` [PATCH v2 3/3] commit: refuse partial commits " Elijah Newren via GitGitGadget
2026-08-27 15:19 ` Phillip Wood
2026-08-27 15:19 ` [PATCH v2 0/3] commit: refuse to amend " Phillip Wood
2026-08-27 16:28 ` Elijah Newren
2026-08-28 7:44 ` [PATCH v3 0/5] " Elijah Newren via GitGitGadget
2026-08-28 7:44 ` [PATCH v3 1/5] commit: clarify FROM_REBASE_PICK and is_from_rebase() names Elijah Newren via GitGitGadget
2026-08-28 15:41 ` Junio C Hamano
2026-08-28 17:27 ` Elijah Newren
2026-08-28 7:44 ` [PATCH v3 2/5] commit: allow a partial commit when a rebase pick becomes empty Elijah Newren via GitGitGadget
2026-08-28 15:46 ` Junio C Hamano
2026-08-28 7:44 ` [PATCH v3 3/5] commit: reword the empty-commit rebase amend error Elijah Newren via GitGitGadget
2026-08-28 15:49 ` Junio C Hamano
2026-08-28 7:44 ` [PATCH v3 4/5] commit: refuse to amend during conflict resolution Elijah Newren via GitGitGadget
2026-08-28 7:44 ` [PATCH v3 5/5] commit: refuse partial commits " Elijah Newren via GitGitGadget
2026-08-28 16:18 ` Junio C Hamano
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=xmqqzey8j1gt.fsf@gitster.g \
--to=gitster@pobox.com \
--cc=git@vger.kernel.org \
--cc=gitgitgadget@gmail.com \
--cc=newren@gmail.com \
--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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.