aboutsummaryrefslogtreecommitdiffstats
path: root/tree.go
diff options
context:
space:
mode:
Diffstat (limited to 'tree.go')
-rw-r--r--tree.go28
1 files changed, 19 insertions, 9 deletions
diff --git a/tree.go b/tree.go
index 8398725..339fb7f 100644
--- a/tree.go
+++ b/tree.go
@@ -39,9 +39,12 @@ func (t *Tree) File(path string) (*File, error) {
return nil, ErrFileNotFound
}
- obj, ok := t.r.Storage.Get(*hash)
- if !ok {
- return nil, ErrFileNotFound // a git submodule
+ obj, err := t.r.Storage.Get(*hash)
+ if err != nil {
+ if err == core.ObjectNotFoundErr {
+ return nil, ErrFileNotFound // a git submodule
+ }
+ return nil, err
}
if obj.Type() != core.BlobObject {
@@ -81,9 +84,12 @@ func (t *Tree) dir(baseName string) (*Tree, error) {
return nil, errDirNotFound
}
- obj, ok := t.r.Storage.Get(entry.Hash)
- if !ok { // git submodule
- return nil, errDirNotFound
+ obj, err := t.r.Storage.Get(entry.Hash)
+ if err != nil {
+ if err == core.ObjectNotFoundErr { // git submodule
+ return nil, errDirNotFound
+ }
+ return nil, err
}
if obj.Type() != core.TreeObject {
@@ -120,9 +126,13 @@ func (t *Tree) Files() chan *File {
func (t *Tree) walkEntries(base string, ch chan *File) {
for _, entry := range t.Entries {
- obj, ok := t.r.Storage.Get(entry.Hash)
- if !ok {
- continue // ignore entries without hash (= submodule dirs)
+ obj, err := t.r.Storage.Get(entry.Hash)
+ if err != nil {
+ if err == core.ObjectNotFoundErr {
+ continue // ignore entries without hash (= submodule dirs)
+ }
+ //FIXME: Refactor this function to return an error. Ideally this would be
+ // moved into a FileIter type.
}
if obj.Type() == core.TreeObject {