Skip to content

Fix conflict resolution from corrupted upstream

Sean McGivern requested to merge fix-conflict-resolution-with-corrupt-repos into master

I don't know exactly what caused this problem, but this fixes https://gitlab.com/gitlab-org/gitlab-ee/issues/2128.

Here's what I wrote in the commit message:

I don't know why this happens exactly, but given an upstream and fork repository from a customer, both of which required GC, resolving conflicts would corrupt the fork so badly that it couldn't be cloned.

This isn't a perfect fix for that case, because the MR may still need to be merged manually, but it does ensure that the repository is at least usable.

My best guess is that when we generate the index for the conflict resolution (which we previously did in the target project), we obtain a reference to an OID that doesn't exist in the source, even though we already fetch the refs from the target into the source.

Explicitly setting the source project as the place to get the merge index from seems to prevent repository corruption in this way.

I can only reproduce on the sample repo provided by the customer; I've been unable to do so with any other repos. So the specs basically check the thing I care about 🤷

The interface from MergeRequest#conflicts could probably be nicer, too.

Merge request reports