#[derive(Clone, Debug)] pub struct RefUpdate { pub name: String, pub old_oid: String, pub new_oid: String, } impl RefUpdate { /// Parse git reference update commands from SSH protocol text. /// Format: " \n" pub fn parse_ref_updates(data: &[u8]) -> Result, String> { let text = String::from_utf8_lossy(data); let mut refs = Vec::new(); for line in text.lines() { let line = line.trim(); if line.is_empty() || line.starts_with('#') || line.starts_with("PACK") { continue; } let mut parts = line.split_whitespace(); let old_oid = parts.next().map(|s| s.to_string()).unwrap_or_default(); let new_oid = parts.next().map(|s| s.to_string()).unwrap_or_default(); let name = parts .next() .unwrap_or("") .trim_start_matches('\0') .to_string(); if !name.is_empty() { refs.push(RefUpdate { old_oid, new_oid, name, }); } } Ok(refs) } }