Reputation: 15057
Our commit logs always start with #workitemid: rest of title
. This poses an issue when writing a commit message, because lines starting with #
are removed by default. Therefore we have the commit.cleanup
setting set to scissors
.
However, it seems like git rebase -i <hash>
using fixup
ignores this setting and errors out with "aborting due to empty commit message".
Is there a known workaround for this behaviour? We are currently on Git version 2.17.1.windows.2
. I am unaware whether this could be fixed in a newer version of Git for Windows.
Upvotes: 2
Views: 150
Reputation: 3841
This works for me on Git 2.46.1.
commit.cleanup
, presumably
because the commits are done non-interactively and man git commit
says that comments are not strippped in that mode [1]fixup!
commitssquash!
commitsAlthough for (3) you get this message:
# This is a combination of 3 commits.
# This is the 1st commit message:
#workitem: more
# This is the commit message #2:
#workitem: more
# This is the commit message #3:
#workitem: moremo rmeore
# ------------------------ >8 ------------------------
# Do not modify or remove the line above.
# Everything below it will be ignored.
[…]
Which means that all the # This is
lines would be kept if you don’t
remove them.
mkdir test
cd test
git init
main_branch=main
git commit --allow-empty -mInit
git checkout -b topic
printf "Read this\n" >readme.md
git add readme.md
git commit -m'#workitem: readme'
git checkout $main_branch
git checkout -b install
printf "How to install (todo)\n" >installation.md
git add installation.md
git commit -m'#workitem: install'
git checkout topic
git rebase install
mkdir test
cd test
git init
main_branch=main
git commit --allow-empty -mInit
git checkout -b topic
printf "Read this\n" >readme.md
git add readme.md
git commit -m'#workitem: readme'
printf "\nAlso read installation doc (todo not written yet)\n" \
>>readme.md
git add readme.md
git commit -m'fixup! #workitem: readme'
GIT_SEQUENCE_EDITOR=: git rebase -i --autosquash main
For this example you do need scissors
since the squash commit editing
session is interactive.
mkdir test
cd test
git init
main_branch=main
git config commit.cleanup scissors
git commit --allow-empty -mInit
git checkout -b topic
printf "Read this\n" >readme.md
git add readme.md
git commit -m'#workitem: readme'
printf "\nAlso read installation doc (todo not written yet)\n" \
>>readme.md
git add readme.md
git commit -m'squash! #workitem: readme'
GIT_EDITOR=cat GIT_SEQUENCE_EDITOR=: git rebase -i --autosquash main
default
) Same as strip
if the message is to be
edited. Otherwise whitespace
.”Upvotes: 0
Reputation: 1
Ran into this problem with git 2.25.1 and started to submit a bug report.
For verification I also tried git 2.35.1 (the newest release) and found this bug seems to have been fixed. I haven't checked the release notes of the in-between version to find out when exactly this change was added.
Upvotes: 0
Reputation: 13582
The release notes of version 2.22.0 have this to say:
The list of conflicted paths shown in the editor while concluding a conflicted merge was shown above the scissors line when the clean-up mode is set to "scissors", even though it was commented out just like the list of updated paths and other information to help the user explain the merge better.
While this does not address your case directly, the change that fixed this item looks like it could also have solved your problem.
You should upgrade to version 2.22.0 at least.
Upvotes: 0