aboutsummaryrefslogtreecommitdiffstats
path: root/plumbing/object/tree.go
diff options
context:
space:
mode:
authorMáximo Cuadros <mcuadros@gmail.com>2017-04-11 20:03:00 +0200
committerMáximo Cuadros <mcuadros@gmail.com>2017-04-11 04:38:46 +0200
commitaa818a3f77e6ff06765cf8c246f8708df3d190a7 (patch)
tree302a5671cfa192f5417ffd5dd5c59447e71e2cb2 /plumbing/object/tree.go
parentaf4f25df56c74b05ae04cc6f2fcac38db1130249 (diff)
downloadgo-git-aa818a3f77e6ff06765cf8c246f8708df3d190a7.tar.gz
plumbing: object, public Tree.FindEntry and minor diff changes
Diffstat (limited to 'plumbing/object/tree.go')
-rw-r--r--plumbing/object/tree.go8
1 files changed, 5 insertions, 3 deletions
diff --git a/plumbing/object/tree.go b/plumbing/object/tree.go
index e70b5cd..b768b96 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