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
Johannes Altmanninger <aclopte@gmail.com>
Date
Sep 17, 2022, 23:19 UTC
Message-ID
<YyZWDkZWAkS7q+Wf@gmail.com>
In-Reply-To
<CA+JQ7M_Xwxa48ggu88rhA9dG6R3u820Tgu8B2Kg-uMbEVjy3Vg@mail.gmail.com>
On Sat, Sep 17, 2022 at 04:45:17PM +0200, Erik Cervin Edin wrote:
Show 17 quoted lines
> Thank you for filling out a Git bug report!
> Please answer the following questions to help us understand your issue.
> 
> What did you do before the bug happened? (Steps to reproduce your issue)
>   dir=rebase-fixup-subject-equals-branch-name
>   mkdir $dir
>   cd $dir
>   git init --initial-branch=main
>   git commit -m init --allow-empty
>   git tag init
> 
>   # 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
Huh, this silently discards the fixup commit, without applying it.

If "foo" is a valid refspec, then the autosquash machinery will apply to it all fixup commits with subject "fixup! foo". The problem you hit is that "foo" points to the fixup commit itself - which is the only destination commit that definitely won't work.

Here is a possible fix:
diff --git a/sequencer.c b/sequencer.c
index 79dad522f5..7cbd8c2595 100644
--- a/sequencer.c
+++ b/sequencer.c
@@ -6231,3 +6231,3 @@ int todo_list_rearrange_squash(struct todo_list *todo_list)
 				 (commit2 =
-				  lookup_commit_reference_by_name(p)) &&
+				  lookup_commit_reference_by_name(p)) != item->commit &&
 				 *commit_todo_item_at(&commit_todo, commit2))
Previous: Erik Cervin EdinNext: Johannes Altmanninger
Message 4 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.