diff options
| author | 2026-03-26 09:19:01 +0000 | |
|---|---|---|
| committer | 2026-03-26 09:19:01 +0000 | |
| commit | 929b8cc620abca70b3444b09be5249f6c6cb7812 (patch) | |
| tree | 29b1edba8f597d09a2a51a6b2c901389cc40e242 /ref/refname/normalize.go | |
| parent | format: Move commitgraph and packfile here (diff) | |
| signature | No signature | |
ref/name: Rename from ref/refname
Diffstat (limited to 'ref/refname/normalize.go')
| -rw-r--r-- | ref/refname/normalize.go | 53 |
1 files changed, 0 insertions, 53 deletions
diff --git a/ref/refname/normalize.go b/ref/refname/normalize.go deleted file mode 100644 index 9cbe7126..00000000 --- a/ref/refname/normalize.go +++ /dev/null @@ -1,53 +0,0 @@ -package refname - -import "strings" - -// Normalize collapses slashes according to what Git wants -// then validates the normalized name. -func Normalize(name string, options Options) (string, error) { - normalized := collapseSlashes(name) - - err := validate(normalized, options.flags()) - if err != nil { - return "", err - } - - return normalized, nil -} - -func normalizeRefPath(path string) (string, bool) { - components := make([]string, 0, strings.Count(path, "/")+1) - i := 0 - - for i < len(path) { - for i < len(path) && path[i] == '/' { - i++ - } - - if i == len(path) { - break - } - - j := i - for j < len(path) && path[j] != '/' { - j++ - } - - component := path[i:j] - switch component { - case ".": - case "..": - if len(components) == 0 { - return "", false - } - - components = components[:len(components)-1] - default: - components = append(components, component) - } - - i = j - } - - return strings.Join(components, "/"), true -} |
