From: Patrick Steinhardt Date: Mon, 27 Apr 2026 05:53:50 GMT Subject: [PATCH v3 0/3] builtin/history: introduce "fixup" subcommand Message-ID: <20260427-b4-pks-history-fixup-v3-0-cb908f06264b@pks.im> In-Reply-To: <20260422-b4-pks-history-fixup-v1-0-48d4484243de@pks.im> Hi, this short patch series introduces a new "fixup" subcommand. This command is the first one that I felt is missing in my day to day work, as I end up doing fixup commits quite often. The flow is rather simple: the user stages some changes, and then they execute `git history fixup ` to amend those changes to the given commit. As with the other subcommands, dependent branches will then be rebased automatically. This is the first command that may result in merge conflicts. For now we simply abort in such cases, but there are plans to introduce first-class conflicts into Git. So once we have them, we'll also be able to handle such cases more gracefully. I still think that the command is useful even without that conflict handling. Changes in v3: - Some more polishing of the command's description. - Link to v2: https://patch.msgid.link/20260423-b4-pks-history-fixup-v2-0-d7571c6d36eb@pks.im Changes in v2: - Introduce "--empty=(keep|drop|abort)" to specify what happens with empty commits. - Adapt documentation a bit to hopefully clarify how changes are backported. - Link to v1: https://patch.msgid.link/20260422-b4-pks-history-fixup-v1-0-48d4484243de@pks.im Thanks! Patrick --- Patrick Steinhardt (3): replay: allow callers to control what happens with empty commits builtin/history: generalize function to commit trees builtin/history: introduce "fixup" subcommand Documentation/git-history.adoc | 78 ++++- builtin/history.c | 291 ++++++++++++++++-- replay.c | 29 +- replay.h | 19 ++ t/meson.build | 1 + t/t3453-history-fixup.sh | 680 +++++++++++++++++++++++++++++++++++++++++ 6 files changed, 1068 insertions(+), 30 deletions(-) Range-diff versus v2: 1: 8840b18095 = 1: 81240d1959 replay: allow callers to control what happens with empty commits 2: b078354b5a = 2: 4f35bba868 builtin/history: generalize function to commit trees 3: 3d1fec55c7 ! 3: ecaded9415 builtin/history: introduce "fixup" subcommand @@ Documentation/git-history.adoc: conflicts. This limitation is by design as histo The following commands are available to rewrite history in different ways: +`fixup `:: -+ Apply the currently staged changes to the specified commit. This -+ is done by performing a three-way merge between the HEAD commit, -+ the target commit and the tree generated from staged changes. -+ This is using the same logic as linkgit:git-cherry-pick[1]. ++ Apply the currently staged changes to the specified commit. This is ++ similar in nature to `git commit --fixup=` followed by `git ++ rebase --autosquash ~`. Changes are applied to the target ++ commit by performing a three-way merge between the HEAD commit, the ++ target commit and the tree generated from staged changes. ++ +The commit message and authorship of the target commit are preserved by +default, unless you specify `--reedit-message`. --- base-commit: 94f057755b7941b321fd11fec1b2e3ca5313a4e0 change-id: 20260422-b4-pks-history-fixup-be27e0c4a03e