aboutsummaryrefslogtreecommitdiffstats
path: root/tree.go
diff options
context:
space:
mode:
authorJoshua Sjoding <joshua.sjoding@scjalliance.com>2016-02-16 03:28:21 -0800
committerJoshua Sjoding <joshua.sjoding@scjalliance.com>2016-02-16 03:28:21 -0800
commite82d4918b403a641a5295b3f199586b0ab26b15c (patch)
tree7b16fa8616393ed911824ff5155f40f1b9c38716 /tree.go
parent45478768e1fa49030b574aec13390fb2d9479836 (diff)
downloadgo-git-e82d4918b403a641a5295b3f199586b0ab26b15c.tar.gz
Functions in core.ObjectStorage interface now return an error
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 {