diff options
author | Máximo Cuadros <mcuadros@gmail.com> | 2017-04-12 15:18:41 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2017-04-12 15:18:41 +0200 |
commit | 932ced9f55f556de02610425cfa161c35c6a758b (patch) | |
tree | 9b5dd9ad1665fad8424dfbdc5bd93b531f714b09 /plumbing/object/tree.go | |
parent | 9b45f468c61a0756dd19d09b64c2b1a88cc99ec5 (diff) | |
parent | 5bcf802213e801c4d52102612f007defa5d0397f (diff) | |
download | go-git-932ced9f55f556de02610425cfa161c35c6a758b.tar.gz |
Merge pull request #339 from mcuadros/status
worktree, status and reset implementation based on merkletrie
Diffstat (limited to 'plumbing/object/tree.go')
-rw-r--r-- | plumbing/object/tree.go | 8 |
1 files changed, 5 insertions, 3 deletions
diff --git a/plumbing/object/tree.go b/plumbing/object/tree.go index e70b5cd..d2265a8 100644 --- a/plumbing/object/tree.go +++ b/plumbing/object/tree.go @@ -67,7 +67,7 @@ type TreeEntry struct { // File returns the hash of the file identified by the `path` argument. // The path is interpreted as relative to the tree receiver. func (t *Tree) File(path string) (*File, error) { - e, err := t.findEntry(path) + e, err := t.FindEntry(path) if err != nil { return nil, ErrFileNotFound } @@ -86,7 +86,7 @@ func (t *Tree) File(path string) (*File, error) { // Tree returns the tree identified by the `path` argument. // The path is interpreted as relative to the tree receiver. func (t *Tree) Tree(path string) (*Tree, error) { - e, err := t.findEntry(path) + e, err := t.FindEntry(path) if err != nil { return nil, ErrDirectoryNotFound } @@ -109,7 +109,8 @@ func (t *Tree) TreeEntryFile(e *TreeEntry) (*File, error) { return NewFile(e.Name, e.Mode, blob), nil } -func (t *Tree) findEntry(path string) (*TreeEntry, error) { +// FindEntry search a TreeEntry in this tree or any subtree. +func (t *Tree) FindEntry(path string) (*TreeEntry, error) { pathParts := strings.Split(path, "/") var tree *Tree @@ -146,6 +147,7 @@ func (t *Tree) entry(baseName string) (*TreeEntry, error) { if t.m == nil { t.buildMap() } + entry, ok := t.m[baseName] if !ok { return nil, errEntryNotFound |