radicle: Compute root OID for older remotes

For older clients, `refs/rad/root` won't be set. In that case, compute
it locally based on `refs/rad/id`.
This commit is contained in:
cloudhead 2024-10-31 17:34:03 +01:00
parent 0c9a7419dc
commit 09f796234d
No known key found for this signature in database
1 changed files with 12 additions and 2 deletions

View File

@ -781,8 +781,18 @@ impl ReadRepository for Repository {
} }
fn identity_root_of(&self, remote: &RemoteId) -> Result<Oid, RepositoryError> { fn identity_root_of(&self, remote: &RemoteId) -> Result<Oid, RepositoryError> {
self.reference_oid(remote, &git::refs::storage::IDENTITY_ROOT) // Remotes that run newer clients will have this reference set. For older clients,
.map_err(RepositoryError::from) // compute the root OID based on the identity head.
if let Ok(root) = self.reference_oid(remote, &git::refs::storage::IDENTITY_ROOT) {
return Ok(root);
}
let oid = self.identity_head_of(remote)?;
let root = self
.revwalk(oid)?
.last()
.ok_or(RepositoryError::Doc(DocError::Missing))??;
Ok(root.into())
} }
fn canonical_identity_head(&self) -> Result<Oid, RepositoryError> { fn canonical_identity_head(&self) -> Result<Oid, RepositoryError> {