RepositoryService.WriteRef: honour `old_revision`
This is a follow-up to #48 (closed)
The old_revision
field of WriteRefRequest
goes straight to the <oldvalue>
argument of git-update-ref(1)
:
NAME
git-update-ref - Update the object name stored in a ref safely
SYNOPSIS
git update-ref [-m <reason>] [--no-deref] (-d <ref> [<oldvalue>] | [--create-reflog] <ref> <newvalue> [<oldvalue>] | --stdin [-z])
(...)
Given three arguments, stores the <newvalue> in the <ref>, possibly dereferencing the symbolic refs, after verifying that
the current value of the <ref> matches <oldvalue>. E.g. git update-ref refs/heads/master <newvalue> <oldvalue> updates
the master branch head to <newvalue> only if its current value is <oldvalue>. You can specify 40 "0" or an empty string
as <oldvalue> to make sure that the ref you are creating does not exist.
At the %HGitaly1: Hg SHAs level, the Rails app calls WriteRef
both for Gitaly (auxiliary Git repo) and HGitaly (the native Mercurial repo). Hence it is enough to perform the check in the Git repository only. This won't be enough for %HGitaly2: fully native
There's also a force
boolean field to investigate.