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

Method EntryById

tree.go:72–85  ·  view source on GitHub ↗

EntryById performs a lookup for a tree entry with the given SHA value. It returns a *TreeEntry that is owned by the Tree. You don't have to free it, but you must not use it after the Tree is freed. Warning: this must examine every entry in the tree, so it is not fast.

(id *Oid)

Source from the content-addressed store, hash-verified

70//
71// Warning: this must examine every entry in the tree, so it is not fast.
72func (t *Tree) EntryById(id *Oid) *TreeEntry {
73 runtime.LockOSThread()
74 defer runtime.UnlockOSThread()
75
76 entry := C.git_tree_entry_byid(t.cast_ptr, id.toC())
77 runtime.KeepAlive(id)
78 if entry == nil {
79 return nil
80 }
81
82 goEntry := newTreeEntry(entry)
83 runtime.KeepAlive(t)
84 return goEntry
85}
86
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)

Callers 1

TestTreeEntryByIdFunction · 0.80

Calls 2

newTreeEntryFunction · 0.85
toCMethod · 0.45

Tested by 1

TestTreeEntryByIdFunction · 0.64