Skip to main content

validate_ref_name

Function validate_ref_name 

Source
pub fn validate_ref_name(name: &str) -> bool
Expand description

Validate a ref name per SPEC-REFS §3. Used at every transport boundary; transports MUST NOT silently lower-case or canonicalise.

Grammar:

  • Non-empty.
  • Segments split on /, each segment matches [A-Za-z0-9._-]+.
  • No . or .. segments. No empty segments (no //, no leading /, no trailing /).
  • No \\ or NUL bytes.
  • No segment may end in .lock (the canonical lock-file suffix).
  • The final segment may not be the literal HEAD, since that would shadow the repo-level HEAD pointer.