diff options
author | Sunny <me@darkowlzz.space> | 2017-12-06 18:51:56 +0530 |
---|---|---|
committer | Máximo Cuadros <mcuadros@gmail.com> | 2017-12-06 14:21:56 +0100 |
commit | eb74b0e1a0ae20075435aded41bffc522bc3554c (patch) | |
tree | 573952f76c2c311d1cf0cbf7627c6af4a68071dc /storage/filesystem/object.go | |
parent | f96d46d38f67604f204711ea0e2832e6e047e2ad (diff) | |
download | go-git-eb74b0e1a0ae20075435aded41bffc522bc3554c.tar.gz |
storage: filesystem, add support for git alternates (#663)
This change adds a new method Alternates() in DotGit to check and
query alternate source.
Diffstat (limited to 'storage/filesystem/object.go')
-rw-r--r-- | storage/filesystem/object.go | 21 |
1 files changed, 21 insertions, 0 deletions
diff --git a/storage/filesystem/object.go b/storage/filesystem/object.go index 6ca67cc..fd52ed5 100644 --- a/storage/filesystem/object.go +++ b/storage/filesystem/object.go @@ -160,6 +160,27 @@ func (s *ObjectStorage) EncodedObject(t plumbing.ObjectType, h plumbing.Hash) (p obj, err = s.getFromPackfile(h, false) } + // If the error is still object not found, check if it's a shared object + // repository. + if err == plumbing.ErrObjectNotFound { + dotgits, e := s.dir.Alternates() + if e == nil { + // Create a new object storage with the DotGit(s) and check for the + // required hash object. Skip when not found. + for _, dg := range dotgits { + o, oe := newObjectStorage(dg) + if oe != nil { + continue + } + enobj, enerr := o.EncodedObject(t, h) + if enerr != nil { + continue + } + return enobj, nil + } + } + } + if err != nil { return nil, err } |