Push mirroring to repository causes the source repository to change its default branch

Summary

With push mirroring set up between two repositories, a push sync from a source/upstream repository will cause its default branch to change according to whatever is set as default downstream, instead of the opposite as you'd expect.

Steps to reproduce

  1. Set up push mirroring from one repository in Gitlab to some other repository elsewhere (in our case, in another self-hosted instance of Gitlab)
  2. Create two branches in the upstream repo (a default, e.g. 'master' and a second one, e.g. 'develop')
  3. Sync once to set up the downstream repo.
  4. Change the default branch of the downstream to the second, non-default branch. ('develop')
  5. Trigger a re-sync from the upstream side.

Example Project

https://gitlab.com/dminer/push-mirror-example and https://gitlab.com/dminer/push-mirror-example-downstream. Following the steps above reproduced the problem.

What is the current bug behavior?

Whenever a re-sync occurs, the upstream repository will have its default branch changed to whatever the downstream's is.

What is the expected correct behavior?

The upstream default branch shouldn't change - at most, the downstream's should change to match upstream instead of the other way around.

Output of checks

This bug happens on GitLab.com.

Possible fixes

It seems like this was introduced in 11.3. My guess would be that it's related to the changes made for this: https://gitlab.com/gitlab-org/gitlab-ee/issues/7211

Assignee Loading
Time tracking Loading