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

Re: [PATCH v4 0/5] commit: refuse to amend during conflict resolution

From
PWPhillip Wood <phillip.wood123@gmail.com>
Date
Sep 2, 2026, 15:41 UTC
Message-ID
<03b9f094-c969-4309-b2cc-f7cd01959d49@gmail.com>
In-Reply-To
<pull.2389.v4.git.git.1788301481.gitgitgadget@gmail.com>
Hi Elijah

The changes from v2 look good, I've got mixed feelings about the new patch 2 but I'm happy with everything else. Thanks for working on it

Phillip
On 01/09/2026 23:24, Elijah Newren via GitGitGadget wrote:
Show 229 quoted lines
> Changes since v3:
> 
>   * Just a clarifying rename, but applied in 3 places:
>     * FROM_REBASE_EMPTY -> FROM_REBASE_NOW_EMPTY
>     * is_from_rebase_empty() -> is_from_rebase_now_empty()
>     * ONGOING_REBASE_EMPTY -> ONGOING_REBASE_NOW_EMPTY
> 
> Changes since v2:
> 
>   * Two new preparatory patches:
>     * Rename FROM_REBASE_PICK and is_from_rebase() to point out they are
>       about empty commits
>     * Allow a partial commit when a rebase pick becomes empty
>   * Tweaked the error message for attempted amend on now-dropped empty commit
>     (suggestions for further improvements welcome)
>   * Used the path accessor functions within sequencer.c to simplify the new
>     helper function
> 
> Both git commit --amend and a partial commit (git commit <paths>) are
> foot-guns while the user is in the middle of an operation that resolves
> conflicts on top of HEAD: recording a conflict resolution is about capturing
> the state of the whole tree as a new commit, not about rewriting HEAD or
> committing a subset of paths.
> 
> Historically we only rejected these during a merge or a cherry-pick or when
> resolving an empty pick during a rebase. The same hazard exists for am,
> revert, and rebase conflict stops, none of which were covered. This series
> extends the refusal to all of them.
> 
> The three patches:
> 
>   1. reword the two pre-existing "empty commit" rebase messages, which were
>      misleadingly generic
>   2. refuse git commit --amend during these additional operations
>   3. refuse partial commits during the same operations.
> 
> Elijah Newren (5):
>    commit: clarify FROM_REBASE_PICK and is_from_rebase() names
>    commit: allow a partial commit when a rebase pick becomes empty
>    commit: reword the empty-commit rebase amend error
>    commit: refuse to amend during conflict resolution
>    commit: refuse partial commits during conflict resolution
> 
>   builtin/commit.c                |  65 +++++++++++-----
>   sequencer.c                     |  59 ++++++++++++++-
>   sequencer.h                     |  24 ++++++
>   t/t3404-rebase-interactive.sh   | 128 +++++++++++++++++++++++++++++++-
>   t/t3507-cherry-pick-conflict.sh |  22 ++++++
>   t/t4151-am-abort.sh             |  22 ++++++
>   wt-status.h                     |   6 +-
>   7 files changed, 299 insertions(+), 27 deletions(-)
> 
> 
> base-commit: 2c3adbb2c475981e340c79fdc5e7f4f9b5d9054e
> Published-As: https://github.com/gitgitgadget/git/releases/tag/pr-git-2389%2Fnewren%2Frefuse-amend-during-conflicts-v4
> Fetch-It-Via: git fetch https://github.com/gitgitgadget/git pr-git-2389/newren/refuse-amend-during-conflicts-v4
> Pull-Request: https://github.com/git/git/pull/2389
> 
> Range-diff vs v3:
> 
>   1:  7e198a20fa ! 1:  bd361679b9 commit: clarify FROM_REBASE_PICK and is_from_rebase() names
>       @@ Commit message
>            specifically about hitting a commit that becomes empty when rebasing.
>            Clarify their names now.
>        
>       -    While at it, change `whence == FROM_REBASE_EMPTY` to use
>       -    `is_from_rebase_empty(whence)`.
>       +    While at it, change `whence == FROM_REBASE_NOW_EMPTY` to use
>       +    `is_from_rebase_now_empty(whence)`.
>        
>            Signed-off-by: Elijah Newren <newren@gmail.com>
>        
>       @@ builtin/commit.c: static const char *prepare_index(const char **argv, const char
>         		else if (is_from_cherry_pick(whence))
>         			die(_("cannot do a partial commit during a cherry-pick."));
>        -		else if (is_from_rebase(whence))
>       -+		else if (is_from_rebase_empty(whence))
>       ++		else if (is_from_rebase_now_empty(whence))
>         			die(_("cannot do a partial commit during a rebase."));
>         	}
>         
>       @@ builtin/commit.c: static int prepare_to_commit(const char *index_file, const cha
>         	else if (whence == FROM_MERGE)
>         		hook_arg1 = "merge";
>        -	else if (is_from_cherry_pick(whence) || whence == FROM_REBASE_PICK) {
>       -+	else if (is_from_cherry_pick(whence) || is_from_rebase_empty(whence)) {
>       ++	else if (is_from_cherry_pick(whence) || is_from_rebase_now_empty(whence)) {
>         		hook_arg1 = "commit";
>         		hook_arg2 = "CHERRY_PICK_HEAD";
>         	}
>       @@ builtin/commit.c: static int prepare_to_commit(const char *index_file, const cha
>         			fputs(_(empty_amend_advice), stderr);
>         		else if (is_from_cherry_pick(whence) ||
>        -			 whence == FROM_REBASE_PICK) {
>       -+			 is_from_rebase_empty(whence)) {
>       ++			 is_from_rebase_now_empty(whence)) {
>         			fputs(_(empty_cherry_pick_advice), stderr);
>         			if (whence == FROM_CHERRY_PICK_SINGLE)
>         				fputs(_(empty_cherry_pick_advice_single), stderr);
>       @@ builtin/commit.c: static int parse_and_validate_options(int argc, const char *ar
>         		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)
>       -+		else if (is_from_rebase_empty(whence))
>       ++		else if (is_from_rebase_now_empty(whence))
>         			die(_("You are in the middle of a rebase -- cannot amend."));
>         	}
>         	if (fixup_message && squash_message)
>       @@ builtin/commit.c: static int parse_and_validate_options(int argc, const char *ar
>         		use_message = "HEAD";
>         	if (!use_message && !is_from_cherry_pick(whence) &&
>        -	    !is_from_rebase(whence) && renew_authorship)
>       -+	    !is_from_rebase_empty(whence) && renew_authorship)
>       ++	    !is_from_rebase_now_empty(whence) && renew_authorship)
>         		die(_("--reset-author can be used only with -C, -c or --amend."));
>         	if (use_message) {
>         		use_message_buffer = read_commit_message(use_message);
>       @@ builtin/commit.c: static int parse_and_validate_options(int argc, const char *ar
>         		}
>         	}
>        -	if ((is_from_cherry_pick(whence) || whence == FROM_REBASE_PICK) &&
>       -+	if ((is_from_cherry_pick(whence) || is_from_rebase_empty(whence)) &&
>       ++	if ((is_from_cherry_pick(whence) || is_from_rebase_now_empty(whence)) &&
>         	    !renew_authorship) {
>         		author_message = "CHERRY_PICK_HEAD";
>         		author_message_buffer = read_commit_message(author_message);
>       @@ builtin/commit.c: int cmd_commit(int argc,
>         			reflog_msg = is_from_cherry_pick(whence)
>         					? "commit (cherry-pick)"
>        -					: is_from_rebase(whence)
>       -+					: is_from_rebase_empty(whence)
>       ++					: is_from_rebase_now_empty(whence)
>         					? "commit (rebase)"
>         					: "commit";
>         		commit_list_insert(current_head, &parents);
>       @@ sequencer.c: int sequencer_determine_whence(struct repository *r, enum commit_wh
>         		    !repo_get_oid(r, "CHERRY_PICK_HEAD", &cherry_pick_head) &&
>         		    oideq(&rebase_head, &cherry_pick_head))
>        -			*whence = FROM_REBASE_PICK;
>       -+			*whence = FROM_REBASE_EMPTY;
>       ++			*whence = FROM_REBASE_NOW_EMPTY;
>         		else
>         			*whence = FROM_CHERRY_PICK_SINGLE;
>         
>       @@ wt-status.h: enum commit_whence {
>         	FROM_CHERRY_PICK_SINGLE, /* commit came from cherry-pick */
>         	FROM_CHERRY_PICK_MULTI, /* commit came from a sequence of cherry-picks */
>        -	FROM_REBASE_PICK /* commit came from a pick/reword/edit */
>       -+	FROM_REBASE_EMPTY /* rebase applied a pick that became empty */
>       ++	FROM_REBASE_NOW_EMPTY /* rebase applied a pick that became empty */
>         };
>         
>         static inline int is_from_cherry_pick(enum commit_whence whence)
>       @@ wt-status.h: static inline int is_from_cherry_pick(enum commit_whence whence)
>         }
>         
>        -static inline int is_from_rebase(enum commit_whence whence)
>       -+static inline int is_from_rebase_empty(enum commit_whence whence)
>       ++static inline int is_from_rebase_now_empty(enum commit_whence whence)
>         {
>        -	return whence == FROM_REBASE_PICK;
>       -+	return whence == FROM_REBASE_EMPTY;
>       ++	return whence == FROM_REBASE_NOW_EMPTY;
>         }
>         
>         struct wt_status_change_data {
>   2:  e169303619 ! 2:  a0b9900437 commit: allow a partial commit when a rebase pick becomes empty
>       @@ builtin/commit.c: static const char *prepare_index(const char **argv, const char
>         			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_empty(whence))
>       +-		else if (is_from_rebase_now_empty(whence))
>        -			die(_("cannot do a partial commit during a rebase."));
>         	}
>         
>   3:  0850a999da ! 3:  c4511a9887 commit: reword the empty-commit rebase amend error
>       @@ builtin/commit.c
>        @@ builtin/commit.c: 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 (is_from_rebase_empty(whence))
>       + 		else if (is_from_rebase_now_empty(whence))
>        -			die(_("You are in the middle of a rebase -- cannot amend."));
>        +			die(_("The now-empty commit has been dropped -- cannot amend."));
>         	}
>   4:  9f80d8a00d ! 4:  e77b34c1cf commit: refuse to amend during conflict resolution
>       @@ builtin/commit.c: static int parse_and_validate_options(int argc, const char *ar
>        -		else if (is_from_cherry_pick(whence))
>        +		case ONGOING_CHERRY_PICK:
>         			die(_("You are in the middle of a cherry-pick -- cannot amend."));
>       --		else if (is_from_rebase_empty(whence))
>       -+		case ONGOING_REBASE_EMPTY:
>       +-		else if (is_from_rebase_now_empty(whence))
>       ++		case ONGOING_REBASE_NOW_EMPTY:
>         			die(_("The now-empty commit has been dropped -- cannot amend."));
>        +		case ONGOING_REVERT:
>        +			die(_("You are in the middle of a revert -- cannot amend."));
>       @@ sequencer.c: int sequencer_determine_whence(struct repository *r, enum commit_wh
>        +	case FROM_CHERRY_PICK_SINGLE:
>        +	case FROM_CHERRY_PICK_MULTI:
>        +		return ONGOING_CHERRY_PICK;
>       -+	case FROM_REBASE_EMPTY:
>       -+		return ONGOING_REBASE_EMPTY;
>       ++	case FROM_REBASE_NOW_EMPTY:
>       ++		return ONGOING_REBASE_NOW_EMPTY;
>        +	case FROM_COMMIT:
>        +		break;
>        +	}
>       @@ sequencer.h: int sequencer_get_last_command(struct repository* r,
>        +	ONGOING_NONE = 0,
>        +	ONGOING_MERGE,
>        +	ONGOING_CHERRY_PICK,
>       -+	ONGOING_REBASE_EMPTY,
>       ++	ONGOING_REBASE_NOW_EMPTY,
>        +	ONGOING_REVERT,
>        +	ONGOING_AM,
>        +	ONGOING_REBASE_CONFLICT
>   5:  050b9e8a52 ! 5:  b93b26ed9f commit: refuse partial commits during conflict resolution
>       @@ builtin/commit.c: static const char *prepare_index(const char **argv, const char
>        +		die(_("cannot do a partial commit during a merge."));
>        +	case ONGOING_CHERRY_PICK:
>        +		die(_("cannot do a partial commit during a cherry-pick."));
>       -+	case ONGOING_REBASE_EMPTY:
>       ++	case ONGOING_REBASE_NOW_EMPTY:
>        +		/*
>        +		 * A pick that became empty is not a conflict, and creating
>        +		 * a new commit (partial or not) poses no problem.
> 
Previous: Elijah Newren via GitGitGadget
Message 43 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.