aboutsummaryrefslogtreecommitdiffstats
path: root/storage
diff options
context:
space:
mode:
authorMiguel Molina <miguel@erizocosmi.co>2018-07-19 15:20:10 +0200
committerMiguel Molina <miguel@erizocosmi.co>2018-07-19 15:20:10 +0200
commit009f1069a1248c1e9189a9e4c342f6d017156ec4 (patch)
treeac984b72e7c54160b0b154bffd4474f96ae5028e /storage
parent9f00789688d26191a987fdec8bc2678362ec4453 (diff)
downloadgo-git-009f1069a1248c1e9189a9e4c342f6d017156ec4.tar.gz
plumbing/format/idxfile: add new Index and MemoryIndex
Signed-off-by: Miguel Molina <miguel@erizocosmi.co>
Diffstat (limited to 'storage')
-rw-r--r--storage/filesystem/index.go47
-rw-r--r--storage/filesystem/object.go2
2 files changed, 1 insertions, 48 deletions
diff --git a/storage/filesystem/index.go b/storage/filesystem/index.go
deleted file mode 100644
index 2ebf57e..0000000
--- a/storage/filesystem/index.go
+++ /dev/null
@@ -1,47 +0,0 @@
-package filesystem
-
-import (
- "os"
-
- "gopkg.in/src-d/go-git.v4/plumbing/format/index"
- "gopkg.in/src-d/go-git.v4/storage/filesystem/dotgit"
- "gopkg.in/src-d/go-git.v4/utils/ioutil"
-)
-
-type IndexStorage struct {
- dir *dotgit.DotGit
-}
-
-func (s *IndexStorage) SetIndex(idx *index.Index) (err error) {
- f, err := s.dir.IndexWriter()
- if err != nil {
- return err
- }
-
- defer ioutil.CheckClose(f, &err)
-
- e := index.NewEncoder(f)
- err = e.Encode(idx)
- return err
-}
-
-func (s *IndexStorage) Index() (i *index.Index, err error) {
- idx := &index.Index{
- Version: 2,
- }
-
- f, err := s.dir.Index()
- if err != nil {
- if os.IsNotExist(err) {
- return idx, nil
- }
-
- return nil, err
- }
-
- defer ioutil.CheckClose(f, &err)
-
- d := index.NewDecoder(f)
- err = d.Decode(idx)
- return idx, err
-}
diff --git a/storage/filesystem/object.go b/storage/filesystem/object.go
index 9ffe4dc..ef67f50 100644
--- a/storage/filesystem/object.go
+++ b/storage/filesystem/object.go
@@ -63,7 +63,7 @@ func (s *ObjectStorage) loadIdxFile(h plumbing.Hash) (err error) {
}
defer ioutil.CheckClose(f, &err)
- idxf := idxfile.NewIdxfile()
+ idxf := idxfile.NewMemoryIndex()
d := idxfile.NewDecoder(f)
if err = d.Decode(idxf); err != nil {
return err