MCPcopy Create free account
hub / github.com/libgit2/git2go / ReferenceNormalizeName

Function ReferenceNormalizeName

reference.go:525–541  ·  view source on GitHub ↗

ReferenceNormalizeName normalizes the reference name and checks validity. This will normalize the reference name by removing any leading slash '/' characters and collapsing runs of adjacent slashes between name components into a single slash. See git_reference_symbolic_create() for rules about val

(name string, flags ReferenceFormat)

Source from the content-addressed store, hash-verified

523//
524// See git_reference_symbolic_create() for rules about valid names.
525func ReferenceNormalizeName(name string, flags ReferenceFormat) (string, error) {
526 cname := C.CString(name)
527 defer C.free(unsafe.Pointer(cname))
528
529 buf := (*C.char)(C.malloc(_refnameMaxLength))
530 defer C.free(unsafe.Pointer(buf))
531
532 runtime.LockOSThread()
533 defer runtime.UnlockOSThread()
534
535 ecode := C.git_reference_normalize_name(buf, _refnameMaxLength, cname, C.uint(flags))
536 if ecode < 0 {
537 return "", MakeGitError(ecode)
538 }
539
540 return C.GoString(buf), nil
541}

Callers 1

Calls 2

MakeGitErrorFunction · 0.85
freeMethod · 0.80

Tested by 1

Used in the wild real call sites across dependent graphs

searching dependent graphs…