Skip to main content

git_ref_invalid_reason

Function git_ref_invalid_reason 

Source
pub fn git_ref_invalid_reason(branch: &str) -> Option<String>
Expand description

Check if a string is a valid git branch name. Returns None if valid, or Some(reason) if invalid. Based on git’s check-ref-format rules:

  • Cannot contain spaces, tabs, or control characters
  • Cannot contain .. (dotdot)
  • Cannot contain @{ (at brace)
  • Cannot start with . or end with .lock
  • Cannot contain /./ or // or end with /
  • Cannot be @ or contain @{ (reflog syntax)