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

Method Create

reference.go:47–72  ·  view source on GitHub ↗
(name string, id *Oid, force bool, msg string)

Source from the content-addressed store, hash-verified

45}
46
47func (c *ReferenceCollection) Create(name string, id *Oid, force bool, msg string) (*Reference, error) {
48 cname := C.CString(name)
49 defer C.free(unsafe.Pointer(cname))
50
51 var cmsg *C.char
52 if msg == "" {
53 cmsg = nil
54 } else {
55 cmsg = C.CString(msg)
56 defer C.free(unsafe.Pointer(cmsg))
57 }
58
59 var ptr *C.git_reference
60
61 runtime.LockOSThread()
62 defer runtime.UnlockOSThread()
63
64 ecode := C.git_reference_create(&ptr, c.repo.ptr, cname, id.toC(), cbool(force), cmsg)
65 runtime.KeepAlive(c)
66 runtime.KeepAlive(id)
67 if ecode < 0 {
68 return nil, MakeGitError(ecode)
69 }
70
71 return newReferenceFromC(ptr, c.repo), nil
72}
73
74func (c *ReferenceCollection) CreateSymbolic(name, target string, force bool, msg string) (*Reference, error) {
75 cname := C.CString(name)

Callers

nothing calls this directly

Calls 5

cboolFunction · 0.85
MakeGitErrorFunction · 0.85
newReferenceFromCFunction · 0.85
freeMethod · 0.80
toCMethod · 0.45

Tested by

no test coverage detected