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

From: Junio C Hamano <[email-masked]>
Date: Sat, 17 Sep 2022 11:04:07 -0700

Erik Cervin Edin <[email-masked]> writes:

>   git init --initial-branch=main
>   git commit -m init --allow-empty
>   git tag init

Thanks for a report.  Let me quickly respond with an initial
reaction without being in front of a real computer to run tests on
myself.  Others may give more useful feedback.

>   # 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.

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?

The title of your bug report is also curious.  What happens if you
did

    git branch -m master

just before running the "rebase" command in the above sequence?  I
would have expected to see that in your "expected" section to
contrast the behaviour between "if subject = branch" vs "if subject
!= branch", and the report looks a bit puzzling.

THanks.