[go: up one dir, main page]

DefaultBranchName returns an arbitrary branch if HEAD points to a non-existing branch

A Geo customer ran into an issue where the RPC for retrieving the default branch was incorrectly returning the wrong branch name. The sequence of events that led to this:

  1. The Geo primary had a default branch of v1.0.
  2. On the Geo secondary, a new project was created with a default HEAD pointing to refs/heads/master.
  3. The Geo secondary issued a FetchRemote for the primary project, removing the branch master.
  4. The Geo secondary sent a DefaultBranchName request and got back v1.0, even though HEAD pointed to a non-existent refs/heads/master.

Step 4 happens because in https://gitlab.com/gitlab-org/gitaly/blob/55c8f124608b22288b2fee99ec8295d3fd980e12/internal/service/ref/refs.go#L160, DefaultBranchName will always return the first branch if there is only one.

This is confusing behavior because it doesn't match with what HEAD reports.

We may want another RPC that will returns the branch pointed by HEAD or fails if it doesn't exist.

Edited by Stan Hu