Adopt "followremotehead" for mirror fetches and bundles
Context
!7500 (merged) disables new behaviour in Git that sets the local HEAD to match the remote HEAD when fetching into a bare repository with a mirror refspec. The MR was created to address failing nightly tests and to give us time to assess if we can simply adopt the new behaviour.
Proposal
Understand the changes introduced in the patch series and see if we can adopt this behaviour by default. Gitaly performs a mirror fetch in the following places:
- https://gitlab.com/gitlab-org/gitaly/blob/13ea55ce58e3ede1a993845edde1183deb32adb1/internal/git/localrepo/bundle.go#L166
- https://gitlab.com/gitlab-org/gitaly/blob/f2759e40236c9cf2af116828d7bb8a4170246ffe/internal/gitaly/service/cleanup/rewrite_history.go#L172
- https://gitlab.com/gitlab-org/gitaly/blob/5676ec7d15c24f64a46e81ba568cb0336e372605/internal/gitaly/service/repository/replicate.go#L306
The FetchBundle()
function in particular has an UpdateHead option, which when set, causes us to extract the HEAD reference from the bundle and manually set the HEAD in the target repo. This is primarily used by restores as the default branch is stored as part of the backup manifest.