#9

repository.proto says HEAD can be moved like a ref; nothing can move it

OpenFoorackopened 2d ago

Two comments in the contract disagree about whether a repository's default branch can change after the repository exists, and the code sides with the one that says no.

What the contract says

repository.proto (v0.4.1) says of Repository.default_branch:

Where HEAD points. Set at creation and never changed here — moving it is a ref update like any other.

I read that as: RepositoryService won't move it, but RefService.UpdateRefs will, the same way that call moves refs/heads/main.

ref.proto says the opposite, about the same field:

The repository's refs, and the branch HEAD points at. HEAD is not one of the refs.

What the code does

The code behaves like ref.proto: an update named HEAD comes back REASON_INVALID_REFNAME with no message, because a ref name has to start with refs/. FetchFromRemote can't do it either, and refuses a HEAD prefix for the same reason.

So as far as I can tell there is no way to change the default branch once a repository exists, despite that first comment.

Which is intended?

  • HEAD is meant to be movable. Making UpdateRefs accept it would be the smallest way to say so: no new RPC, and it is what the comment already advertises.
  • HEAD is fixed at creation. Then the comment in repository.proto should say what the other two files say, instead of pointing at a call that refuses.

Either answer works for me. I just wanted to check that the contract says what it means.

Activity

0

No activity yet.