Squash merge of MR with 0 changes fails
Summary
Merging a MR with 0 changes (so 1 or more empty commits) with "Squash commits when merge request is accepted." checked fails with:
Merge failed: Failed to squash. Should be done manually.. Please try again.
Steps to reproduce
git commands:
git checkout -b new_branch
git commit --allow-empty -m "commit"
git push
through gitlab:
- create MR of branch
new_branch
, check option "Squash commits when merge request is accepted." - try to merge it - it should fail
Example Project
mfolnovic/gitlab-merge-squash-bug!1
What is the current bug behavior?
When merging, I get an error:
Merge failed: Failed to squash. Should be done manually.. Please try again.
What is the expected correct behavior?
It should merge in a same way it would merge if option "Squash commits when merge request is accepted." was not checked.
In case of my example project, I'd expect one empty commit with given squash commit message and one merge commit.
Relevant logs and/or screenshots
Possible fixes
I assume you are doing git commit
after git merge --squash
, which will fail since there are no local changes at that point. Maybe doing git commit --allow-empty
is acceptable.
Or at least give a failure message that explains what happened.