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

Method Dwim

reference.go:140–155  ·  view source on GitHub ↗

Dwim looks up a reference by DWIMing its short name

(name string)

Source from the content-addressed store, hash-verified

138
139// Dwim looks up a reference by DWIMing its short name
140func (c *ReferenceCollection) Dwim(name string) (*Reference, error) {
141 cname := C.CString(name)
142 defer C.free(unsafe.Pointer(cname))
143
144 runtime.LockOSThread()
145 defer runtime.UnlockOSThread()
146
147 var ptr *C.git_reference
148 ret := C.git_reference_dwim(&ptr, c.repo.ptr, cname)
149 runtime.KeepAlive(c)
150 if ret < 0 {
151 return nil, MakeGitError(ret)
152 }
153
154 return newReferenceFromC(ptr, c.repo), nil
155}
156
157func newReferenceFromC(ptr *C.git_reference, repo *Repository) *Reference {
158 ref := &Reference{ptr: ptr, repo: repo}

Callers 1

TestUtilFunction · 0.80

Calls 3

MakeGitErrorFunction · 0.85
newReferenceFromCFunction · 0.85
freeMethod · 0.80

Tested by 1

TestUtilFunction · 0.64