Cherry-picking a merged MR fails, when the content changed by the MR was also updated in the default branch

Summary

One of our customers reported that cherry-picking a merged MR fails, when the content changed by the MR was also updated in the default branch

Steps to reproduce

  • create a new branch of a project (let's call it new-branch-to-pick)

  • make a commit to the branch new-branch-to-pick and create an MR to master branch

  • merge this MR to master

  • switch to the master branch, make commit by changing the same string that was changed in the previously made commit

  • go to the merged MR, click cherry-pick to master, you will see the message:

    Sorry, we cannot cherry-pick this merge request automatically. This merge request may already have been cherry-picked, or a more recent commit may have updated some of its content.

Example Project

Reproduced with the test project https://gitlab.com/atanayno/learn-rails/ MR that I tried to cherry-pick: https://gitlab.com/atanayno/learn-rails/merge_requests/1

What is the current behavior?

The message Sorry, we cannot cherry-pick this merge request automatically. This merge request may already have been cherry-picked, or a more recent commit may have updated some of its content. is shown.

What is the expected behavior?

There should probably be an ability to resolve such case via UI: create MR with conflicts.

Relevant logs and/or screenshots

Screenshot attachedScreen_Shot_2018-04-27_at_3.54.58_PM

Additional info

As a workaround, it is possible to do cherry-picking manually in a local repository:

1. create a cherry-pick branch based on master
2. cherry-pick the merge commit made by the merged merge request into the cherry-pick branch. This will result in a conflict.
3. resolve this conflicts, commit the conflict resolution and merge the cherry-pick branch into master via a new merge request.

Similar question was also asked a couple of times at stack overflow:

https://stackoverflow.com/questions/46322142/creation-of-merge-request-in-gitlab-fails https://stackoverflow.com/questions/49670336/gitlab-sorry-we-cannot-cherry-pick-this-merge-request-automatically

Output of checks

This issue happens on GitLab.com.

Results of GitLab environment info

n/a

Results of GitLab application Check

n/a

/cc @smcgivern

Edited by Alexandr Tanayno