Thread (43 messages) flat view 43 messages, 4 authors, 3d ago

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

From: Elijah Newren <hidden>
Date: 2026-08-27 00:23:48

On Wed, Aug 26, 2026 at 9:22 AM Junio C Hamano [off-list ref] wrote:
"Elijah Newren via GitGitGadget" [off-list ref] writes:
quoted
...  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.
Oh, good callout.  And later in commit.c we do disallow those, but
only for the same operations we previously disallowed and amend
during:

        commit_style = COMMIT_PARTIAL;

        if (whence != FROM_COMMIT) {
                if (whence == FROM_MERGE)
                        die(_("cannot do a partial commit during a merge."));
                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."));
        }

The exact same additional structure could apply there, and that kind
of reinforces Phillip's suggestion to factor out a helper that we can
call.  I did that in v2.
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help