From 249c4137f4f34992c9bb6a60954e30a27994add7 Mon Sep 17 00:00:00 2001 From: Máximo Cuadros Date: Thu, 15 Dec 2016 13:45:52 +0100 Subject: storage: shallow storage (#180) * storage: shallow storage * changes * changes --- storage/memory/storage.go | 13 +++++++++++++ 1 file changed, 13 insertions(+) (limited to 'storage/memory') diff --git a/storage/memory/storage.go b/storage/memory/storage.go index a912e94..ecf2efa 100644 --- a/storage/memory/storage.go +++ b/storage/memory/storage.go @@ -18,6 +18,7 @@ var ErrUnsupportedObjectType = fmt.Errorf("unsupported object type") type Storage struct { ConfigStorage ObjectStorage + ShallowStorage ReferenceStorage } @@ -26,6 +27,7 @@ func NewStorage() *Storage { return &Storage{ ReferenceStorage: make(ReferenceStorage, 0), ConfigStorage: ConfigStorage{}, + ShallowStorage: ShallowStorage{}, ObjectStorage: ObjectStorage{ Objects: make(map[plumbing.Hash]plumbing.EncodedObject, 0), Commits: make(map[plumbing.Hash]plumbing.EncodedObject, 0), @@ -195,3 +197,14 @@ func (r ReferenceStorage) IterReferences() (storer.ReferenceIter, error) { return storer.NewReferenceSliceIter(refs), nil } + +type ShallowStorage []plumbing.Hash + +func (s *ShallowStorage) SetShallow(commits []plumbing.Hash) error { + *s = commits + return nil +} + +func (s ShallowStorage) Shallow() ([]plumbing.Hash, error) { + return s, nil +} -- cgit