From: Junio C Hamano <gitster@pobox.com>
To: Pablo Sabater <pabloosabaterr@gmail.com>
Cc: git@vger.kernel.org, Patrick Steinhardt <ps@pks.im>,
Kaartic Sivaraam <kaartic.sivaraam@gmail.com>
Subject: Re: [PATCH RFC 1/2] builtin/history: abort reword on unchanged message
Date: Mon, 08 Jun 2026 05:16:35 -0700 [thread overview]
Message-ID: <xmqqmrx5z0po.fsf@gitster.g> (raw)
In-Reply-To: <20260607-ps-history-reword-v1-1-ba43a3cbb81b@gmail.com> (Pablo Sabater's message of "Sun, 07 Jun 2026 22:07:20 +0200")
Pablo Sabater <pabloosabaterr@gmail.com> writes:
> When using `git history reword` if the new message is the same as the
> original it continues anyway creating a new commit with the same
> message and updates its descendants, modifying the history after this
> 'reworded' commit even though there was no actual change.
>
> `git commit --amend` and `git rebase -i` + reword share this behavior,
> however `git history reword` is different:
> 1. Works in-memory without touching the index or the worktree [1], so
> there are no side effects like staged files that could justify
> rewriting the history when the commit message is the same.
> 2. `git history` by default updates all the branches [2] that contain the
> original commit making it more costly than `git rebase -i` that only
> updates the current branch.
I think the reasoning is flawed.
Both "git commit --amend" and "git rebase -i", even with no changes
to the tree, parents, or the message, update the committer timestamp
(and perhaps the committer identity running the command may be
different from the original). Updating this info is one of the
important effects of the command.
And "history" being more capable than "rebase" is a wrong excuse to
make the system behave inconsistently between commands that have
similar features [*1*]. In a situation where letting 'history'
update all the relevant branches, if a command behaves differently
from the way the user likes (and if the way 'rebase -i' works is the
one the user likes), you'd end up forcing the user to use 'rebase
-i' when 'history' would have been more appropriate.
Having said that, I personally think that the current behaviour of
`commit --amend` and `history reword` are both _wrong_ [*2*].
You may start `git commit --amend`, and after staring at the
existing commit log message for some time in your editor, it is
quite natural for you to decide that leaving the commit as-is is the
right thing [*3*] in your situation. It may have been a better
design for the system to notice this situation and leave the commit
as-is, with an override option `--force` to allow users to forcibly
update the committer ident and timestamp in the commit header. I am
not a `history reword` user (yet), but from the motivation you
described for this patch, I sense that the story is the same there.
`git rebase -i A`, when A is truly an ancestor at the bottom of a
linear history leading to HEAD, behaves slightly better. It gives
you a todo list with a bunch of `pick` insns, and when you do not
edit earliest 'pick's the todo list, these earliest commits are left
as-is. It may still share the same issue that a 'reword' that you
ended up not rewording (or 'edit' that you ended up not touching its
tree or log message) does still recreate a new commit object, though.
`git rebase -i` may have an excuse that because it, unlike "git
commit --amend", operates on multiple commits by design. A single
"--force" option given to the command would not have worked as an
escape hatch to allow the user to tell the command "in this reword
of this particular commit, I ended up doing nothing, but I still
want an updated committer log timestamp". Perhaps giving the
"--force" (or --force-rewrite") option at "rebase --continue" time
may work, but in any case, unless we plan to transition to these
"better" default behaviour at a big version boundary, speculating
what a "better" behaviour would have been may be fun but not very
productive.
[Footnote]
*1* Besides, doesn't "--update-refs" in "rebase -i" allow you to
adjust the branches?
*2* But it is an established behaviour people _rely_ on, so even
though it may have been better if these commands behaved
differently, it probably is a bit too late to change it now.
*3* This includes the case where the original author is especially
difficult to work with and would complain any change to their
commits, even if the only change you made for them is a
typofix. Fixing a small typo/grammo may not be worth your time
and unpleasant exchanges with them after touching their commit.
next prev parent reply other threads:[~2026-06-08 12:16 UTC|newest]
Thread overview: 13+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-06-07 20:07 [PATCH RFC 0/2] builtin/history: change git history reword behavior and feedback Pablo Sabater
2026-06-07 20:07 ` [PATCH RFC 1/2] builtin/history: abort reword on unchanged message Pablo Sabater
2026-06-08 9:30 ` Patrick Steinhardt
2026-06-08 10:52 ` Pablo Sabater
2026-06-08 12:16 ` Junio C Hamano [this message]
2026-06-08 16:44 ` Ben Knoble
2026-06-08 16:37 ` Ben Knoble
2026-06-07 20:07 ` [PATCH RFC 2/2] builtin/history: print feedback after successful reword Pablo Sabater
2026-06-08 9:30 ` Patrick Steinhardt
2026-06-08 10:45 ` Pablo Sabater
2026-06-08 12:16 ` Junio C Hamano
2026-06-08 13:23 ` Pablo Sabater
2026-06-08 16:47 ` Ben Knoble
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=xmqqmrx5z0po.fsf@gitster.g \
--to=gitster@pobox.com \
--cc=git@vger.kernel.org \
--cc=kaartic.sivaraam@gmail.com \
--cc=pabloosabaterr@gmail.com \
--cc=ps@pks.im \
/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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox