diff options
| author | Carlos Martín Nieto <[email protected]> | 2015-08-31 13:49:17 +0200 |
|---|---|---|
| committer | Carlos Martín Nieto <[email protected]> | 2015-08-31 13:55:46 +0200 |
| commit | f72db33baf9a47fc8b0d0ad8e83881eba235b532 (patch) | |
| tree | 0869cd25b8ea03495f35bcb42eb908cc72afb6af /tree.go | |
| parent | 157593f38da780c4f6cb6dc61275b9b36a3327bf (diff) | |
| parent | c6c2e9389fd2148d20f2e283000f5b4204dbcdc8 (diff) | |
Merge branch 'next'
Diffstat (limited to 'tree.go')
| -rw-r--r-- | tree.go | 18 |
1 files changed, 18 insertions, 0 deletions
@@ -55,6 +55,24 @@ func (t Tree) EntryByName(filename string) *TreeEntry { return newTreeEntry(entry) } +// 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. +func (t Tree) EntryById(id *Oid) *TreeEntry { + runtime.LockOSThread() + defer runtime.UnlockOSThread() + + entry := C.git_tree_entry_byid(t.cast_ptr, id.toC()) + if entry == nil { + return nil + } + + return newTreeEntry(entry) +} + // EntryByPath looks up an entry by its full path, recursing into // deeper trees if necessary (i.e. if there are slashes in the path) func (t Tree) EntryByPath(path string) (*TreeEntry, error) { |
