Radish alpha
h
rad:z3gqcJUoA1n9HaHKufZs5FCSGazv5
Radicle Heartwood Protocol & Stack
Radicle
Git
fetch/transport/ls_refs: Post-filter of references
Fintan Halpenny committed 2 months ago
commit 8070f98a5b8a12c532314b789607326c7eb1984f
parent 980ed56
1 file changed +14 -0
modified 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 <https://git-scm.com/docs/protocol-v2#_ls_refs>.
+
    let refs = refs
+
        .into_iter()
+
        .filter(|r| {
+
            let (refname, _, _) = r.unpack();
+
            config
+
                .prefixes
+
                .iter()
+
                .any(|prefix| refname.starts_with(prefix))
+
        })
+
        .collect();
+

    Ok(refs)
}