From a4e66d141e02a3b1e58b21b4c67cab61a971da5a Mon Sep 17 00:00:00 2001 From: Defelo Date: Tue, 13 Jan 2026 14:45:57 +0100 Subject: [PATCH] radicle: Allow all references to be included in sigrefs Previously, the `references_of` implementation restricted the set of references to certain categories: heads, tags, notes, rad, and cobs. This is too restrictive to allow peers to share any references they want. The only exceptions is references `refs/tmp/heads` that are created for creating patches. --- CHANGELOG.md | 5 +++++ crates/radicle/src/storage/git.rs | 30 +++++++++++++++++------------- 2 files changed, 22 insertions(+), 13 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 8f3591ef..7116b6bd 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -11,6 +11,11 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 ## New Features +- The set of references returned by `references_of` were restricted to `heads`, + `tags`, `notes`, `rad`, and `cobs`. The restriction is lifted, and the only + references filtered out are `refs/tmp/heads` – used by `radicle-remote-helper` + to create temporary patches. + ## Fixed Bugs ## Deprecations diff --git a/crates/radicle/src/storage/git.rs b/crates/radicle/src/storage/git.rs index 223f61de..887481c4 100644 --- a/crates/radicle/src/storage/git.rs +++ b/crates/radicle/src/storage/git.rs @@ -739,6 +739,17 @@ impl ReadRepository for Repository { .graph_descendant_of(head.into(), ancestor.into()) } + /// The published references of the given `remote`. + /// + /// Note that this includes all references, including `refs/rad/sigrefs`. + /// This reference must be removed before signing the payload. + /// + /// # Skipped References + /// + /// References created by [`staging::patch`], i.e. references that begin + /// with `refs/tmp/heads`, are skipped. + /// + /// [`staging::patch`]: crate::git::refs::storage::staging::patch fn references_of(&self, remote: &RemoteId) -> Result { let entries = self .backend @@ -750,20 +761,13 @@ impl ReadRepository for Repository { let name = e.name().ok_or(Error::InvalidRef)?; let (_, refname) = git::parse_ref::(name)?; let oid = e.resolve()?.target().ok_or(Error::InvalidRef)?; - let (_, category, _, _) = refname.non_empty_components(); + let (_, category, subcategory, _) = refname.non_empty_components(); - use git::fmt::{component, name}; - - if [ - name::HEADS, - name::TAGS, - name::NOTES, - &component!("rad"), - &component!("cobs"), - ] - .contains(&category.as_ref()) - { - refs.insert(refname.into(), oid.into()); + match (category.as_str(), subcategory.as_str()) { + ("tmp", "heads") => continue, + _ => { + refs.insert(refname.into(), oid.into()); + } } } Ok(refs.into())