A mapped ref name: well-formed Git reference name under `refs/` (git-check-ref-format's exclusions, simplified to the durable subset).
(value: Option<&str>)
| 334 | /// A mapped ref name: well-formed Git reference name under `refs/` |
| 335 | /// (git-check-ref-format's exclusions, simplified to the durable subset). |
| 336 | fn validate_ref_name(value: Option<&str>) -> PristineResult<()> { |
| 337 | let Some(value) = value else { |
| 338 | return Ok(()); |
| 339 | }; |
| 340 | let forbidden = [b'~', b'^', b':', b'?', b'*', b'[', b'\\', 0x7f]; |
| 341 | let well_formed = value.starts_with("refs/") |
| 342 | && !value.ends_with('/') |
| 343 | && !value.ends_with(".") |
| 344 | && !value.contains("..") |
| 345 | && !value.contains("//") |
| 346 | && !value.contains("@{") |
| 347 | && !value.ends_with(".lock") |
| 348 | && value |
| 349 | .bytes() |
| 350 | .all(|b| b.is_ascii_graphic() && !forbidden.contains(&b)); |
| 351 | if !well_formed { |
| 352 | return Err(PristineError::Serialization { |
| 353 | message: format!("ref mapping ref name is not a well-formed Git reference: {value:?}"), |
| 354 | }); |
| 355 | } |
| 356 | Ok(()) |
| 357 | } |
| 358 | |
| 359 | fn encode_len_prefixed(bytes: &mut Vec<u8>, value: &[u8]) -> PristineResult<()> { |
| 360 | if value.len() > u16::MAX as usize { |