Reopening an old closed MR silently throws away the commits

Summary

Reopening an MR that has been closed for long enough that refs/merge-requests/NNNN/head has been deleted, and for which the source branch has also been deleted, succeeds but silently and unexpectedly changes the MR to contain zero commits, losing the ability to even look at the diffs which was possible prior to the reopen.

Steps to reproduce

  1. Create a merge request with some commits in the source branch.
  2. Close the merge request.
  3. Delete the source branch.
  4. Wait 14 days so that refs/merge-request/NNNN/head is deleted.
  5. Reopen the merge request.

What is the current bug behavior?

The reopen button immediately reopens the merge request, which then claims to have no commits or changes.

What is the expected correct behavior?

Either:

  1. If the commits still exist as Git objects, recreate refs/merge-requests/NNNN/head and retain the commits in the MR.
  2. If the commits no longer exist as Git objects, but only as something in the web UI (they are still there, you can still see the commits and diffs in the web UI!), then show a warning that reopening the MR will lose that information, apparently forever.
Edited by 🤖 GitLab Bot 🤖