From: Junio C Hamano <gitster@pobox.com>
To: "Harald Nordgren via GitGitGadget" <gitgitgadget@gmail.com>
Cc: git@vger.kernel.org, Harald Nordgren <haraldnordgren@gmail.com>
Subject: Re: [PATCH 0/2] commit: preserve commit hash on a no-op amend
Date: Sat, 13 Jun 2026 08:44:21 -0700 [thread overview]
Message-ID: <xmqq33yqfnsa.fsf@gitster.g> (raw)
In-Reply-To: <pull.2334.git.git.1781342189.gitgitgadget@gmail.com> (Harald Nordgren via GitGitGadget's message of "Sat, 13 Jun 2026 09:16:27 +0000")
"Harald Nordgren via GitGitGadget" <gitgitgadget@gmail.com> writes:
> git commit --amend --no-edit rewrote the commit and moved the branch tip
> even when nothing changed, because the committer date was reset to "now".
> Reuse the existing committer date so a no-op amend keeps the commit hash and
> leaves the branch untouched.
>
> A real change (tree, message, author, committer, or signing) still rewrites
> as before.
I think this change brings nothing but regression.
Isn't it obvious that "commit --amend --no-edit" without updating
any tree contents would record exactly the same contents as before,
without a "real change" (as you said above), to any and all users,
expert and casual alike?
The end-user who runs such a command must have a reason to do so.
The *ONLY* valid reason anybody might want to such an amend is to
make sure the result is a new object, even if it records otherwise
the same content.
Why would they want to do so? Perhaps it is so that future merges
of the topic branch that contains the commit will work more smoothly
into an integration branch that had earlier merged the topic branch,
and then that earlier merge was reverted. This change will rob an
effective way to ensure a successful final merge in a workflow to
(1) merge a topic, (2) revert the topic, (3) update near the tip of
the topic while keeping earlier topic intact, and then (4) merge the
result again.
So, no. I do not think this is a good change.
Let's digress and imagine an alternate universe where rebase/commit
--amend/history were "smart" from day one. These command in such a
hypothetical world may not be capable of refreshing an existing
commit without making any "real change".
Making a change to these commands to _optionally_ allow them to
recreate an otherwise unchanged commit, so that it will get a new
object name, would be a welcome change that would allow users who
would use "commit --amend --no-edit" with today's system for such a
use case.
And that would have been a logical evolution of the system in such a
hypothetical world.
But the thing is, we do not live in such a world.
If we still think that alternate hypothetical world is a better
place, we'd need to actively move things around, carefully designing
the transition to avoid harming existing users along the way, to get
there. Changing the behaviour all of a sudden and breaking existing
workflows is not something we do around here.
One way to get to such a world might be:
* Introduce an "committer timestamp is a trashable information"
option, and teach commands like "commit --amend", "rebase", and
"history" to cheat and yield the existing commit without
refreshing when they are asked to recreate an existing commit
while the option is in effect. Give people the opposite
"committer timestamp is not trashable information" option, so an
earlier "is trashable" option on the command line can be
countermanded by giving it later on the command line.
* Have users discuss if "is trashable" is a better default, and
gain consensus to make it the default in a future version of Git.
Advertise the fact that we achieved consensus LOUDLY, while
telling dissidents that "is not trashable" option will forever be
available for them.
* At a big version boundary, switch the default.
And I do not think I in principle would object to the first step of
such a three step process.
Thanks.
next prev parent reply other threads:[~2026-06-13 15:44 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-06-13 9:16 [PATCH 0/2] commit: preserve commit hash on a no-op amend Harald Nordgren via GitGitGadget
2026-06-13 9:16 ` [PATCH 1/2] commit: extract commit_index_files_or_die() helper Harald Nordgren via GitGitGadget
2026-06-13 9:16 ` [PATCH 2/2] commit: keep the commit on a no-op amend Harald Nordgren via GitGitGadget
2026-06-13 9:59 ` [PATCH 0/2] commit: preserve commit hash " Johannes Sixt
2026-06-13 14:07 ` Ben Knoble
2026-06-13 15:44 ` Junio C Hamano [this message]
2026-06-13 16:15 ` Harald Nordgren
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=xmqq33yqfnsa.fsf@gitster.g \
--to=gitster@pobox.com \
--cc=git@vger.kernel.org \
--cc=gitgitgadget@gmail.com \
--cc=haraldnordgren@gmail.com \
/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