From b304997a387a5106321fe87069a6f136d9fbd1f6 Mon Sep 17 00:00:00 2001 From: James Ravn Date: Thu, 5 Jul 2018 10:50:09 +0100 Subject: plumbing: object, expose ErrEntryNotFound in FindEntry. Fixes #883 FindEntry will return ErrDirNotFound if the directory doesn't exist. But it doesn't return a public error if the entry itself is missing. This exposes the internal error ErrEntryNotFound, so users can programmatically check for this condition. Signed-off-by: James Ravn --- plumbing/object/tree.go | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) (limited to 'plumbing/object/tree.go') diff --git a/plumbing/object/tree.go b/plumbing/object/tree.go index 30bbcb0..7d9e90b 100644 --- a/plumbing/object/tree.go +++ b/plumbing/object/tree.go @@ -25,6 +25,7 @@ var ( ErrMaxTreeDepth = errors.New("maximum tree depth exceeded") ErrFileNotFound = errors.New("file not found") ErrDirectoryNotFound = errors.New("directory not found") + ErrEntryNotFound = errors.New("entry not found") ) // Tree is basically like a directory - it references a bunch of other trees @@ -166,8 +167,6 @@ func (t *Tree) dir(baseName string) (*Tree, error) { return tree, err } -var errEntryNotFound = errors.New("entry not found") - func (t *Tree) entry(baseName string) (*TreeEntry, error) { if t.m == nil { t.buildMap() @@ -175,7 +174,7 @@ func (t *Tree) entry(baseName string) (*TreeEntry, error) { entry, ok := t.m[baseName] if !ok { - return nil, errEntryNotFound + return nil, ErrEntryNotFound } return entry, nil -- cgit