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

Re: [BUG] fixup commit is dropped during rebase if subject = branch name

From
EEErik Cervin Edin <erik@cervined.in>
Date
Sep 18, 2022, 14:55 UTC
Message-ID
<CA+JQ7M9_o-0W1orXnPRGzoLziE0HBNkLe0HugGNFKxy0LPsgXA@mail.gmail.com>
In-Reply-To
<xmqqpmftev3c.fsf@gitster.g>
On Sat, Sep 17, 2022, 8:04 PM Junio C Hamano <gitster@pobox.com> wrote:
Show 11 quoted lines
>
> >   # failure
> >   seq 1 3 >> bar && git add bar && git commit -m main
> >   git tag -f x
> >   seq 4 6 >> bar && git add bar && git commit -m bar
> >   seq 7 9 >> bar && git add bar && git commit --fixup :/main
> >   git -c sequence.editor=: rebase --autosquash --interactive x
> >   git diff ORIG_HEAD
>
> So near the bottom there are "init", and "x".  The commit title of
> "x" is "main" and that is what the fix-up intends to amend.
Yes, sorry if that was unclear. So the branch looks like
  474b082 (HEAD -> main) fixup! main
  acd367f bar
  576294e (tag: x) main
  dd27847 (tag: init) init
so
  git -c sequence.editor rebase -i --autosquash x
should yield
  474b082 (HEAD -> main) fixup! main
  acd367f bar
  576294e (tag: x) main
  dd27847 (tag: init) init
ie. no change, but instead yields
  acd367f (HEAD -> main) bar
  576294e (tag: x) main
  dd27847 (tag: init) init

ie. it drops the fixup! main commit but only if it's the first commit, see second example I posted

On Sat, Sep 17, 2022 at 4:45 PM Erik Cervin Edin <erik@cervined.in> wrote:
Show 8 quoted lines
>   # normal
>   git reset --hard init
>   seq 1 3 >> bar && git add bar && git commit -m main
>   git tag -f x
>   seq 4 6 >> bar && git add bar && git commit --fixup :/main
>   seq 7 9 >> bar && git add bar && git commit -m bar
>   git -c sequence.editor=: rebase --autosquash --interactive x
>   git diff ORIG_HEAD
yields
  acd367f (HEAD -> main) bar
  474b082 fixup! main
  576294e (tag: x) main
  dd27847 (tag: init) init
as expected.
Show 5 quoted lines
> But then I do not think there is any valid expectation if you say
> "keep x intact and rebase everything above", which is what the
> command line arguments tell the last command to do.  Perhaps we
> should keep all original commits up to that "fixup" one without any
> reordering or squashing?

I'm not sure I follow but the report is concerning the unexpected behavior of dropping the commit under these specific conditions. I'm not 100% sure but as I recall, this only happens in situation where the fixup may not be applied (and in which case it should remain as is).

> The title of your bug report is also curious.  What happens if you
> did
>
>     git branch -m master
that works as expected
  git reset --hard init
  seq 1 3 >> bar && git add bar && git commit -m main
  git tag -f x
  seq 4 6 >> bar && git add bar && git commit -m bar
  seq 7 9 >> bar && git add bar && git commit --fixup :/main
  git branch -m master
  git -c sequence.editor=: rebase --autosquash --interactive x
but changing branch -m to switch -c reproduces the bug
  6650ace (HEAD -> master) bar
  7835cd5 (tag: x) main
  368ed2f (tag: init) init
Hope this better clarifies what is going on!
Previous: Junio C HamanoNext: Johannes Altmanninger
Message 3 of 19 in “[BUG] fixup commit is dropped during rebase if subject = branch name”
  1. Erik Cervin EdinSep 17, 2022
  2. Junio C HamanoSep 17, 2022
  3. Erik Cervin EdinSep 18, 2022
  4. Johannes AltmanningerSep 17, 2022
  5. sequencer: avoid dropping fixup commit that targets self via commit-ishJohannes Altmanninger, Sep 18, 2022
  6. Erik Cervin EdinSep 18, 2022
  7. Johannes AltmanningerSep 18, 2022
  8. Junio C HamanoSep 19, 2022
  9. Junio C HamanoSep 19, 2022
  10. Johannes AltmanningerSep 20, 2022
  11. Junio C HamanoSep 19, 2022
  12. sequencer: avoid dropping fixup commit that targets self via commit-ishJohannes Altmanninger, Sep 20, 2022
  13. Phillip WoodSep 20, 2022
  14. Junio C HamanoSep 21, 2022
  15. Johannes AltmanningerSep 22, 2022
  16. Junio C HamanoSep 22, 2022
  17. sequencer: avoid dropping fixup commit that targets self via commit-ishJohannes Altmanninger, Sep 24, 2022
  18. Junio C HamanoSep 19, 2022
  19. Johannes AltmanningerSep 20, 2022

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.