This small series contains two commits that aim to improve `git history reword`: 1. Abort the reword when the original message and the new message are the same to avoid unnecessary history changes. 2. Print feedback after a successful reword so the user knows about it.
`git commit --amend` and `git rebase -i` with reword don't abort if the commit message is the same as the original and they update as if it was a new message in favor of changing this behavior for `git history reword`: - As noted in the `git history` documentation, the command by default updates all branches that contain the original commit [1] this makes `git history reword` more expensive than other options like `git rebase -i` that only updates the current branch. - `git history` works in-memory without touching the worktree or index [2], because it doesn't use the sequencer and `git history reword` doesn't care about the staged files only about the commit message, it should have no problems.
About the last fact in favor of 1, I'm not completely sure if it's because of staged files that's the reason why `git commit --amend` or `git rebase -i` with reword still updates even if the commit message is the same one. I'm not very up to sequencer.c to be sure but maybe there's a historical reason about it that someone knows. Anyways I believe that given this new command is a good idea to discuss it.
The commit message of 1 mentions staged files as a possible justification for why --amend and rebase behave this way, but that's just an assumption that I'll be happy to change if I'm wrong.
[1]: https://git-scm.com/docs/git-history#_description [2]: https://lore.kernel.org/git/20260113-b4-pks-history-builtin-v11-8-e74ebfa2652d@pks.im/
To: git@vger.kernel.org Cc: Patrick Steinhardt <ps@pks.im> Cc: Kaartic Sivaraam <kaartic.sivaraam@gmail.com>
Signed-off-by: Pablo Sabater <pabloosabaterr@gmail.com>
---
Pablo Sabater (2):
builtin/history: abort reword on unchanged message
builtin/history: print feedback after successful rewordbuiltin/history.c | 14 ++++++++++++++ t/t3451-history-reword.sh | 34 ++++++++++++++++++++++++++++++++++ 2 files changed, 48 insertions(+) --- base-commit: 9ac3f193c05c2237e2b14ebaa1149e9fc8a1abe0 change-id: 20260607-ps-history-reword-fcb70eaa4aa9
Best regards, -- Pablo Sabater <pabloosabaterr@gmail.com>