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

Function ReferenceNameIsValid

reference.go:489–502  ·  view source on GitHub ↗

ReferenceNameIsValid returns whether the reference name is well-formed. Valid reference names must follow one of two patterns: 1. Top-level names must contain only capital letters and underscores, and must begin and end with a letter. (e.g. "HEAD", "ORIG_HEAD"). 2. Names prefixed with "refs/" can

(name string)

Source from the content-addressed store, hash-verified

487// the characters '~', '^', ':', ' \ ', '?', '[', and '*', and the sequences
488// ".." and " @ {" which have special meaning to revparse.
489func ReferenceNameIsValid(name string) (bool, error) {
490 cname := C.CString(name)
491 defer C.free(unsafe.Pointer(cname))
492
493 runtime.LockOSThread()
494 defer runtime.UnlockOSThread()
495
496 var valid C.int
497 ret := C.git_reference_name_is_valid(&valid, cname)
498 if ret < 0 {
499 return false, MakeGitError(ret)
500 }
501 return valid == 1, nil
502}
503
504const (
505 // This should match GIT_REFNAME_MAX in src/refs.h

Callers 2

TestReferenceNameIsValidFunction · 0.85
ReferenceIsValidNameFunction · 0.85

Calls 2

MakeGitErrorFunction · 0.85
freeMethod · 0.80

Tested by 1

TestReferenceNameIsValidFunction · 0.68

Used in the wild real call sites across dependent graphs

searching dependent graphs…