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

Re: [PATCH 0/2] commit: preserve commit hash on a no-op amend

From
Johannes Sixt <j6t@kdbg.org>
Date
Jun 13, 2026, 09:59 UTC
Message-ID
<355d4f1a-147c-47e3-ab09-06810d7910c0@kdbg.org>
In-Reply-To
<pull.2334.git.git.1781342189.gitgitgadget@gmail.com>
Am 13.06.26 um 11:16 schrieb Harald Nordgren via GitGitGadget:
> 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.

`git commit --amend --no-edit` is a way to set the committer timestamp to the current time without changing other aspects of the commit. This takes away this ability, doesn't it?

Is this keyed to --no-edit? Why is this mode special? Wouldn't it be an identical case when the commit message is passed to the editor, but comes back unchanged?

An invocation of `git commit` asks to "please make a new commit". But in the suggested mode, no new commit is created. Shouldn't this then be regarded as failure?

What happens with the current branch? Is it left unchanged (no ref update occurs) or is it changed (a ref update occurs, but it happens to be a no-op)? And does this then generate a reflog entry?

The updated documentation says about signed commits (note: I am totally clueless about commit signing procedures):

> A commit that is being signed (`-S`, or `commit.gpgsign`)
> is always rewritten, since its signature cannot reproduce the original.

But if the commit doesn't change in any way, why should the signature be invalidated, rewritten, or updated?

-- Hannes
Previous: Harald Nordgren via GitGitGadgetNext: Ben Knoble
Message 4 of 7 in “commit: preserve commit hash on a no-op amend”
  1. 0/2 commit: preserve commit hash on a no-op amendHarald Nordgren via GitGitGadget, Jun 13, 2026
  2. 1/2 commit: extract commit_index_files_or_die() helperHarald Nordgren via GitGitGadget, Jun 13, 2026
  3. 2/2 commit: keep the commit on a no-op amendHarald Nordgren via GitGitGadget, Jun 13, 2026
  4. Johannes SixtJun 13, 2026
  5. Ben KnobleJun 13, 2026
  6. Junio C HamanoJun 13, 2026
  7. Harald NordgrenJun 13, 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.