MCPcopy Create free account
hub / github.com/antonmedv/gitmal / parseName

Function parseName

pkg/gitdiff/file_header.go:423–436  ·  view source on GitHub ↗

parseName extracts a file name from the start of a string and returns the name and the index of the first character after the name. If the name is unquoted and term is non-zero, parsing stops at the first occurrence of term. If the name is exactly "/dev/null", no further processing occurs. Otherwis

(s string, term byte, dropPrefix int)

Source from the content-addressed store, hash-verified

421// separated by forward slashes are dropped from the name and any duplicate
422// slashes are collapsed.
423func parseName(s string, term byte, dropPrefix int) (name string, n int, err error) {
424 if len(s) > 0 && s[0] == '"' {
425 name, n, err = parseQuotedName(s)
426 } else {
427 name, n, err = parseUnquotedName(s, term)
428 }
429 if err != nil {
430 return "", 0, err
431 }
432 if name == devNull {
433 return name, n, nil
434 }
435 return cleanName(name, dropPrefix), n, nil
436}
437
438func parseQuotedName(s string) (name string, n int, err error) {
439 for n = 1; n < len(s); n++ {

Callers 8

TestParseNameFunction · 0.85
parseGitHeaderOldNameFunction · 0.85
parseGitHeaderNewNameFunction · 0.85
parseGitHeaderCopyFromFunction · 0.85
parseGitHeaderCopyToFunction · 0.85
parseGitHeaderRenameFromFunction · 0.85
parseGitHeaderRenameToFunction · 0.85

Calls 3

parseQuotedNameFunction · 0.85
parseUnquotedNameFunction · 0.85
cleanNameFunction · 0.85

Tested by 1

TestParseNameFunction · 0.68