Skip to main content

Module check_ref_format

Module check_ref_format 

Source
Expand description

Ref-name validation — git check-ref-format rules.

This module implements the same validation logic as git check_refname_format() in git/refs.c, including the --allow-onelevel, --refspec-pattern, and --normalize options.

§Rules

A ref name is valid when:

  1. No path component begins with .
  2. No .. anywhere
  3. No ASCII control characters (< 0x20 or DEL 0x7f)
  4. No space, ~, ^, :, ?, [, \
  5. No trailing /
  6. No path component ends with .lock
  7. No @{
  8. Cannot be exactly @
  9. No consecutive slashes // (unless --normalize collapses them)
  10. No leading / (unless --normalize strips it)
  11. No trailing .
  12. Must have at least two slash-separated components (unless --allow-onelevel)

Structs§

RefNameOptions
Options controlling validation.

Enums§

RefNameError
Errors returned by check_refname_format.

Functions§

check_refname_format
Validate refname according to Git ref-name rules.
collapse_slashes
Strip a leading / and collapse consecutive interior slashes to one.