Git does not find commit to !fixup
introduction
I started to use --fixup instead of doing “fixing typo” commits in my branches and with git rebase upstream/main --autosquash I prepared branch for a new MR. Receantly I discovered that in one case this worflow is breaking.
Problem is having whitespace at the start of targeted commit message (see reproduction steps).
After investigating git source code, there is “lstrip” right after skipping the “!fixup: " message so when using hashmap_get_from_hash it uses striped message, hence can not find the commit.
Reason
Rework in a patch from 2017 started to match whole messages but added lstrip trying to help users, which created malformed fixup commits like "fixup: <extra_spaces>Commit message"
see this part in a ^ patch:
while (isspace(*p))
p++;
Reproduce steps
/tmp $ git --version
git version 2.55.0
/tmp $ git init reproducer
/tmp/reproducer/ $ cd reproducer
/tmp/reproducer/ $ git commit --allow-empty -m "Initial commit"
/tmp/reproducer/ $ touch README.md && git add README.md && git commit -m " add all files, but this message starts with space"
/tmp/reproducer/ $ touch .gitignore && git add .gitignore && git commit --fixup HEAD
/tmp/reproducer/ $ git log --oneline | wc -l
3
/tmp/reproducer/ $ git rebase --autosquash HEAD~2 # with or without [-i]
/tmp/reproducer/ $ git log --oneline | wc -l
3
rebase does not fixup commits as expected. There are still 3 commits present.