aboutsummaryrefslogtreecommitdiffstats
path: root/storage/filesystem/internal/index
diff options
context:
space:
mode:
authorMáximo Cuadros <mcuadros@gmail.com>2016-09-08 23:58:41 +0200
committerMáximo Cuadros <mcuadros@gmail.com>2016-09-08 23:58:41 +0200
commit3b1baea2dd9353f42b3a9d93f6bc92ecbe9f4f01 (patch)
treed255b7e6edbcbaba1f98cf0c666a82c0f9750019 /storage/filesystem/internal/index
parent2293a3dbda0a96f5cbac851bb73e1e675417e4f3 (diff)
downloadgo-git-3b1baea2dd9353f42b3a9d93f6bc92ecbe9f4f01.tar.gz
format: packfile based on ObjectStorage and CRC32 calculation
Diffstat (limited to 'storage/filesystem/internal/index')
-rw-r--r--storage/filesystem/internal/index/index.go12
1 files changed, 8 insertions, 4 deletions
diff --git a/storage/filesystem/internal/index/index.go b/storage/filesystem/internal/index/index.go
index 2fd2a55..412b78f 100644
--- a/storage/filesystem/internal/index/index.go
+++ b/storage/filesystem/internal/index/index.go
@@ -1,11 +1,13 @@
package index
import (
+ "fmt"
"io"
"gopkg.in/src-d/go-git.v4/core"
"gopkg.in/src-d/go-git.v4/formats/idxfile"
"gopkg.in/src-d/go-git.v4/formats/packfile"
+ "gopkg.in/src-d/go-git.v4/storage/memory"
)
// Index is a database of objects and their offset in a packfile.
@@ -25,6 +27,7 @@ func (i *Index) Decode(r io.Reader) error {
}
for _, e := range idx.Entries {
+ fmt.Println(e.CRC32)
(*i)[e.Hash] = int64(e.Offset)
}
@@ -33,16 +36,17 @@ func (i *Index) Decode(r io.Reader) error {
// NewFrompackfile returns a new index from a packfile reader.
func NewFromPackfile(r io.Reader) (Index, core.Hash, error) {
- p := packfile.NewScannerFromReader(r)
- d := packfile.NewDecoder(p, nil)
+ o := memory.NewStorage().ObjectStorage()
+ s := packfile.NewScannerFromReader(r)
+ d := packfile.NewDecoder(s, o)
checksum, err := d.Decode()
if err != nil {
return nil, core.ZeroHash, err
}
- index := Index(d.Index())
- return index, checksum, p.Close()
+ index := Index(d.Offsets())
+ return index, checksum, d.Close()
}
// Get returns the offset that an object has the packfile.