Merge fails with "Failed to squash" if the source branch has previously resolved merge conflicts
Summary
Some MRs fail with "Failed to squash" if the source branch has previously resolved merge conflicts
The merge of the two branches is successful when done locally with git merge --squash
and no conflicts appear there.
I also suspect that some of the recent reports in issue Got "Failure to squash" error when trying to me... (#27046 - closed) are also relevant to this issue.
Steps to reproduce
- Create a project with one file with bunch of lines
- Create 2 branches, edit the same line of the file differently in each branch (we want to create a merge conflict)
- Create a new MR to merge branch B into A - it shows that merge conflicts exist.
- Use resolve tool, to resolve conflicts - I picked to keep changes from branch B.
- Conflicts are resolved now, branch A changes are merged into B (but overwritten during the conflict resolution) and MR appears ok to be merged now.
- Now do another commit in each branch - edit a different line in each branch (so no conflicts are created)
- Return to your merge request - it still shows no conflicts, so you can merge now
- Click Merge - and you get "Failed to squash. Should be done manually. Try again." error
Example Project
https://gitlab.com/gitlab-gold/kateg/repro-264610/-/merge_requests/1
What is the current bug behavior?
Unable to merge MR with "Failed to squash"
What is the expected correct behavior?
MR should be merged successfully because all conflicts were already resolved.
Relevant logs and/or screenshots
/var/log/gitlab/gitaly/current:{"correlation_id":"01FVM52Q1AJPX74DWMMQHWRD30","error":"rebasing end onto start commit: rebase: commit \"24a82b485fecf6f2d0ea7e4bb5a1c35f3722092f\": conflicts have not been resolved: rebase: commit \"24a82b485fecf6f2d0ea7e4bb5a1c35f3722092f\": conflicts have not been resolved","grpc.meta.auth_version":"v2","grpc.meta.client_name":"gitlab-sidekiq","grpc.meta.deadline_type":"unknown","grpc.meta.method_type":"unary","grpc.method":"UserSquash","grpc.request.deadline":"2022-02-11T16:25:53.343","grpc.request.fullMethod":"/gitaly.OperationService/UserSquash","grpc.request.glProjectPath":"root/aquash-merge-request-error-264610","grpc.request.glRepository":"project-185","grpc.request.repoPath":"@hashed/61/a2/61a229bae1e90331edd986b6bbbe617f7035de88a5bf7c018c3add6c762a6e8d.git","grpc.request.repoStorage":"default","grpc.service":"gitaly.OperationService","grpc.start_time":"2022-02-11T10:25:53.343","level":"error","msg":"user squash","peer.address":"@","pid":2409179,"remote_ip":"109.87.135.38","span.kind":"server","system":"grpc","time":"2022-02-11T10:25:53.380Z","username":"root"}
Output of checks
This bug happens on GitLab.com
Possible fixes
Workaround
A solution that one of the customer used is to merge target branch into source branch right before merging it the other way.
I was able to merge such MRs from the local copy of the repo + git push origin target-branch
.