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)
| 523 | // |
| 524 | // See git_reference_symbolic_create() for rules about valid names. |
| 525 | func 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 | } |
searching dependent graphs…