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)
| 70 | // |
| 71 | // Warning: this must examine every entry in the tree, so it is not fast. |
| 72 | func (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) |