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

Re: [PATCH RFC 1/2] builtin/history: abort reword on unchanged message

From
Pablo Sabater <pabloosabaterr@gmail.com>
Date
Jun 9, 2026, 15:51 UTC
Message-ID
<CAN5EUNSuuz61pxEk1ZK8RAr0HOtt1f-_mCRpm7RBwoHAcgVAOA@mail.gmail.com>
In-Reply-To
<xmqqtsrbsvcm.fsf@gitster.g>
El mar, 9 jun 2026 a las 15:21, Junio C Hamano (<gitster@pobox.com>) escribió:
Show 60 quoted lines
>
> Pablo Sabater <pabloosabaterr@gmail.com> writes:
>
> > True, after reading it, history being more costly or the in memory are
> > not good args.
>
> And no argument, including that history is new, is a good excuse to
> make these three things inconsistent, period.
>
> One of the patches in your updated iteration claims
>
>     When using `git history reword <commit>` if the new message is the same
>     as the original, it continues and rewrites the history when nothing
>     changed.
>
>     `git commit --amend` and `git rebase -i` with reword share this behavior
>     and it is wrong as well, but changing them breaks what people are used
>     to. Take the opportunity of `git history` being a new command and handle
>     it correctly from the start.
>
> and I think this is a totally wrong attitude to go about this.
>
> I may have said that it may have been a better default to try hard
> to avoid making a change that is a no-op, other than that it changes
> committer timestamp, while making the current "always create a new
> commit object" behaviour optionally available, for these three
> commands, and cited that the behaviour of 'pick' in 'rebase -i' that
> avoids unnecessary rewrite as an example of a good practice.
>
> But I do not think the existing behaviour to always rewrite is
> *wrong* at all.  It may be wrong not to offer the other choice of
> pretending no content change means no commit object change, but that
> is a different story.
>
> I also do not think *aborting* only when the message happens to be
> the same is a valid mode of operation at all.
>
> The most sensible first step, I think, is to add a new command line
> option to "git history" (which will gain more history editing
> subcommands) that tells the command to leave the original history
> as-is when the only change rewriting commits would make would be to
> the committer ident or timestamp information.  If in a future a new
> replace-tree subcommand is added, e.g. if
>
>     $ git history replace-tree HEAD~20 HEAD~27^{tree}
>
> were a command to rewrite the history in such a way that 20th direct
> ancestor of the current HEAD had a tree object HEAD~27^{tree}, by
> derfault the command _should_ rewrite HEAD~10 and everything that
> has it as an ancestor.  With the "--avoid-unnecsssary-rewrite"
> optimization feature on, however, it may silently become a no-op
> when HEAD~27^{tree} happened to be the same tree as HEAD~20^{tree}
> so the only difference between rewritten and original HEAD~20 would
> be when that commit object was created and by whom.
>
> And give the same option to "rebase -i" or "commit --amend".  We can
> discuss, educate the users, and flip the default at a major version
> boundary, if the "avoid unnecessary rewrite" truly turns out to be a
> better default (right now it is merely our speculation, and we do
> not even know if the current behaviour is a worse default).
Hi Junio,

Sorry about how I expressed myself. I didn't mean by wrong to be bad or anything similar, I just noticed this when testing `git history reword` and thought that I would like it this other way.

Saying that git history is new or I would like this to be different are not good arguments to have `git history` inconsistent with other commands.

My idea was more of a defensive thing, where you would need a "--force-rewrite" opt to explicitly change timestamps. But I see the point of having it in an `--avoid-unnecessary-rewrite` so without options it has the same behavior as other commands.

I'll try to express myself better in the next version and go with the opt direction.

Sorry again, Pablo

Previous: Junio C HamanoNext: Ben Knoble
Message 11 of 36 in “builtin/history: change git history reword behavior and feedback”
  1. 0/2 builtin/history: change git history reword behavior and feedbackPablo Sabater, Jun 7, 2026
  2. 1/2 builtin/history: abort reword on unchanged messagePablo Sabater, Jun 7, 2026
  3. Patrick SteinhardtJun 8, 2026
  4. Pablo SabaterJun 8, 2026
  5. Junio C HamanoJun 8, 2026
  6. Ben KnobleJun 8, 2026
  7. Pablo SabaterJun 9, 2026
  8. Pablo SabaterJun 9, 2026
  9. Kristoffer HaugsbakkJun 9, 2026
  10. Junio C HamanoJun 9, 2026
  11. Pablo SabaterJun 9, 2026
  12. Ben KnobleJun 8, 2026
  13. Pablo SabaterJun 9, 2026
  14. 2/2 builtin/history: print feedback after successful rewordPablo Sabater, Jun 7, 2026
  15. Patrick SteinhardtJun 8, 2026
  16. Pablo SabaterJun 8, 2026
  17. Junio C HamanoJun 8, 2026
  18. Pablo SabaterJun 8, 2026
  19. Ben KnobleJun 8, 2026
  20. Dominique MartinetJul 7, 2026
  21. D. Ben KnobleJul 7, 2026
  22. Patrick SteinhardtJul 8, 2026
  23. 0/2 builtin/history: abort reword on same messagePablo Sabater, Jun 9, 2026
  24. 1/2 builtin/history: refactor function signaturePablo Sabater, Jun 9, 2026
  25. 2/2 builtin/history: abort reword on same messagePablo Sabater, Jun 9, 2026
  26. Phillip WoodJun 9, 2026
  27. Junio C HamanoJun 9, 2026
  28. Pablo SabaterJun 9, 2026
  29. Junio C HamanoJun 9, 2026
  30. Patrick SteinhardtJun 10, 2026
  31. Phillip WoodJun 10, 2026
  32. Junio C HamanoJun 10, 2026
  33. Justin ToblerJun 9, 2026
  34. Junio C HamanoJun 9, 2026
  35. Justin ToblerJun 9, 2026
  36. Phillip WoodJun 10, 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.