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

Re: Bug: `git commit --fixup` with duplicate commit messages

From
Rafael Ascensão <rafa.almas@gmail.com>
Date
Dec 14, 2018, 14:00 UTC
Message-ID
<20181214135818.7ta7y5feumzau4g3@rigel>
In-Reply-To
<CADBHO9E7Bzk9C5ciC416S+5-cS2ANA9d+CzSjKSG+HyxwrU+2w@mail.gmail.com>
On Fri, Dec 14, 2018 at 12:30:28PM +0000, Oliver Joseph Ash wrote:
> I believe I have found a bug in `git commit --fixup`.

That's not a bug, it's actually the documented behaviour of rebase --autosquash.

As you figured out, the squash/fixup is based on whether the message has the squash!/fixup! prefix and the subject matches. But it also allows specifying hashes.

So for fixups, you can be explicit and use: git commit -m 'fixup! SHA'.

Similarly for squashes. (But a little less friendly as you'll need to deal with passing an argument to -m that contains newlines).

But adding 'squash! SHA' when the editor opens should also work.

I believe the main reason this works based on subject message matching is to be more friendly with scenarios where you're sharing series of commits that include fixups and squashes. (Either via format patch, or by rebasing the series on a newer base without --autosquash).

On such cases the commit you're trying to fixup will have a different OID, so any hardcoded OID will be useless while commit message matching works most of the time.

One potential improvement to this is to teach --fixup and --squash to also add trailers like: "{fixup,squash}: SHA" or "target: SHA" and teach --autosquash to respect it when possible.

Thoughts?
Previous: Johannes SchindelinNext: John Passaro
Message 3 of 4 in “Bug: `git commit --fixup` with duplicate commit messages”
  1. Oliver Joseph AshDec 14, 2018
  2. Johannes SchindelinDec 14, 2018
  3. Rafael AscensãoDec 14, 2018
  4. John PassaroDec 14, 2018

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.