From 8070f98a5b8a12c532314b789607326c7eb1984f Mon Sep 17 00:00:00 2001 From: Fintan Halpenny Date: Mon, 16 Feb 2026 11:32:17 +0000 Subject: [PATCH] fetch/transport/ls_refs: Post-filter of references The Git protocol specification states about `ls-refs`[^1]: > ref-prefix > When specified, only references having a prefix matching one of > the provided prefixes are displayed. Multiple instances may be > given, in which case references matching any prefix will be > shown. Note that this is purely for optimization; a server MAY > show refs not matching the prefix if it chooses, and clients > should filter the result themselves. The `ref-prefix` arguments should not be relied on and post-filtering after the ls-refs invocation should also be performed. [^1]: https://git-scm.com/docs/protocol-v2#_ls_refs --- crates/radicle-fetch/src/transport/ls_refs.rs | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/crates/radicle-fetch/src/transport/ls_refs.rs b/crates/radicle-fetch/src/transport/ls_refs.rs index c088eb87..16c33fc9 100644 --- a/crates/radicle-fetch/src/transport/ls_refs.rs +++ b/crates/radicle-fetch/src/transport/ls_refs.rs @@ -67,5 +67,19 @@ where false, /* trace packetlines */ )?; + // Even though we sent `ref-prefix`, listed refs must still be + // filtered, since `ref-prefix` is just an optimization hint. + // See . + let refs = refs + .into_iter() + .filter(|r| { + let (refname, _, _) = r.unpack(); + config + .prefixes + .iter() + .any(|prefix| refname.starts_with(prefix)) + }) + .collect(); + Ok(refs) }