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

Method EntryByPath

tree.go:89–105  ·  view source on GitHub ↗

EntryByPath looks up an entry by its full path, recursing into deeper trees if necessary (i.e. if there are slashes in the path)

(path string)

Source from the content-addressed store, hash-verified

87// EntryByPath looks up an entry by its full path, recursing into
88// deeper trees if necessary (i.e. if there are slashes in the path)
89func (t *Tree) EntryByPath(path string) (*TreeEntry, error) {
90 cpath := C.CString(path)
91 defer C.free(unsafe.Pointer(cpath))
92 var entry *C.git_tree_entry
93
94 runtime.LockOSThread()
95 defer runtime.UnlockOSThread()
96
97 ret := C.git_tree_entry_bypath(&entry, t.cast_ptr, cpath)
98 runtime.KeepAlive(t)
99 if ret < 0 {
100 return nil, MakeGitError(ret)
101 }
102 defer C.git_tree_entry_free(entry)
103
104 return newTreeEntry(entry), nil
105}
106
107func (t *Tree) EntryByIndex(index uint64) *TreeEntry {
108 entry := C.git_tree_entry_byindex(t.cast_ptr, C.size_t(index))

Callers 2

entryExistsFunction · 0.45
TestTreeBuilderInsertFunction · 0.45

Calls 3

MakeGitErrorFunction · 0.85
newTreeEntryFunction · 0.85
freeMethod · 0.80

Tested by 2

entryExistsFunction · 0.36
TestTreeBuilderInsertFunction · 0.36