aboutsummaryrefslogtreecommitdiffstats
path: root/formats/packfile
diff options
context:
space:
mode:
authorMáximo Cuadros <mcuadros@gmail.com>2015-10-26 01:22:54 +0100
committerMáximo Cuadros <mcuadros@gmail.com>2015-10-26 01:22:54 +0100
commit688e802814f791a8723874dc88437bd8d140e103 (patch)
treeaeaf5e435e5802d9c8ae855a88128a49bc9768c8 /formats/packfile
parent9a44cd8ccff143a112436c38bfe5581e74b68f07 (diff)
downloadgo-git-688e802814f791a8723874dc88437bd8d140e103.tar.gz
objects: using readers from internal.Object
Diffstat (limited to 'formats/packfile')
-rw-r--r--formats/packfile/reader.go28
-rw-r--r--formats/packfile/reader_test.go14
2 files changed, 21 insertions, 21 deletions
diff --git a/formats/packfile/reader.go b/formats/packfile/reader.go
index 6ccf384..420b9cd 100644
--- a/formats/packfile/reader.go
+++ b/formats/packfile/reader.go
@@ -7,7 +7,7 @@ import (
"io"
"io/ioutil"
- "gopkg.in/src-d/go-git.v2/common"
+ "gopkg.in/src-d/go-git.v2/internal"
"github.com/klauspost/compress/zlib"
)
@@ -50,8 +50,8 @@ type Reader struct {
Format Format
r *trackingReader
- s common.ObjectStorage
- offsets map[int64]common.Hash
+ s internal.ObjectStorage
+ offsets map[int64]internal.Hash
}
// NewReader returns a new Reader that reads from a io.Reader
@@ -60,12 +60,12 @@ func NewReader(r io.Reader) *Reader {
MaxObjectsLimit: DefaultMaxObjectsLimit,
r: &trackingReader{r: r},
- offsets: make(map[int64]common.Hash, 0),
+ offsets: make(map[int64]internal.Hash, 0),
}
}
// Read reads the objects and stores it at the ObjectStorage
-func (r *Reader) Read(s common.ObjectStorage) (int64, error) {
+func (r *Reader) Read(s internal.ObjectStorage) (int64, error) {
r.s = s
if err := r.validateHeader(); err != nil {
if err == io.EOF {
@@ -144,7 +144,7 @@ func (r *Reader) readObjects(count uint32) error {
return nil
}
-func (r *Reader) newRAWObject() (common.Object, error) {
+func (r *Reader) newRAWObject() (internal.Object, error) {
raw := r.s.New()
var steps int64
@@ -153,7 +153,7 @@ func (r *Reader) newRAWObject() (common.Object, error) {
return nil, err
}
- typ := common.ObjectType((buf[0] >> 4) & 7)
+ typ := internal.ObjectType((buf[0] >> 4) & 7)
size := int64(buf[0] & 15)
steps++ // byte we just read to get `o.typ` and `o.size`
@@ -173,11 +173,11 @@ func (r *Reader) newRAWObject() (common.Object, error) {
var err error
switch raw.Type() {
- case common.REFDeltaObject:
+ case internal.REFDeltaObject:
err = r.readREFDelta(raw)
- case common.OFSDeltaObject:
+ case internal.OFSDeltaObject:
err = r.readOFSDelta(raw, steps)
- case common.CommitObject, common.TreeObject, common.BlobObject, common.TagObject:
+ case internal.CommitObject, internal.TreeObject, internal.BlobObject, internal.TagObject:
err = r.readObject(raw)
default:
err = InvalidObjectErr.n("tag %q", raw.Type)
@@ -186,8 +186,8 @@ func (r *Reader) newRAWObject() (common.Object, error) {
return raw, err
}
-func (r *Reader) readREFDelta(raw common.Object) error {
- var ref common.Hash
+func (r *Reader) readREFDelta(raw internal.Object) error {
+ var ref internal.Hash
if _, err := r.r.Read(ref[:]); err != nil {
return err
}
@@ -215,7 +215,7 @@ func (r *Reader) readREFDelta(raw common.Object) error {
return nil
}
-func (r *Reader) readOFSDelta(raw common.Object, steps int64) error {
+func (r *Reader) readOFSDelta(raw internal.Object, steps int64) error {
start := r.r.position
offset, err := decodeOffset(r.r, steps)
if err != nil {
@@ -246,7 +246,7 @@ func (r *Reader) readOFSDelta(raw common.Object, steps int64) error {
return nil
}
-func (r *Reader) readObject(raw common.Object) error {
+func (r *Reader) readObject(raw internal.Object) error {
return r.inflate(raw.Writer())
}
diff --git a/formats/packfile/reader_test.go b/formats/packfile/reader_test.go
index 14c092e..f5cc3e7 100644
--- a/formats/packfile/reader_test.go
+++ b/formats/packfile/reader_test.go
@@ -9,7 +9,7 @@ import (
"testing"
"time"
- "gopkg.in/src-d/go-git.v2/common"
+ "gopkg.in/src-d/go-git.v2/internal"
"github.com/dustin/go-humanize"
. "gopkg.in/check.v1"
@@ -29,7 +29,7 @@ func (s *ReaderSuite) TestReadPackfile(c *C) {
r := NewReader(d)
- storage := common.NewRAWObjectStorage()
+ storage := internal.NewRAWObjectStorage()
_, err := r.Read(storage)
c.Assert(err, IsNil)
@@ -63,7 +63,7 @@ func (s *ReaderSuite) testReadPackfileGitFixture(c *C, file string, f Format) {
r := NewReader(d)
r.Format = f
- storage := common.NewRAWObjectStorage()
+ storage := internal.NewRAWObjectStorage()
_, err = r.Read(storage)
c.Assert(err, IsNil)
@@ -99,10 +99,10 @@ func (s *ReaderSuite) testReadPackfileGitFixture(c *C, file string, f Format) {
})
}
-func AssertObjects(c *C, s *common.RAWObjectStorage, expects []string) {
+func AssertObjects(c *C, s *internal.RAWObjectStorage, expects []string) {
c.Assert(len(expects), Equals, len(s.Objects))
for _, expected := range expects {
- obtained, ok := s.Get(common.NewHash(expected))
+ obtained, ok := s.Get(internal.NewHash(expected))
c.Assert(ok, Equals, true)
c.Assert(obtained.Hash().String(), Equals, expected)
}
@@ -174,14 +174,14 @@ func (s *ReaderSuite) _TestMemoryREF(c *C) {
fmt.Println("time", time.Since(start))
}
-func readFromFile(c *C, file string, f Format) *common.RAWObjectStorage {
+func readFromFile(c *C, file string, f Format) *internal.RAWObjectStorage {
d, err := os.Open(file)
c.Assert(err, IsNil)
r := NewReader(d)
r.Format = f
- storage := common.NewRAWObjectStorage()
+ storage := internal.NewRAWObjectStorage()
_, err = r.Read(storage)
c.Assert(err, IsNil)