diff options
-rw-r--r-- | packfile/objects.go | 19 |
1 files changed, 3 insertions, 16 deletions
diff --git a/packfile/objects.go b/packfile/objects.go index 3c77a33..a73b8c3 100644 --- a/packfile/objects.go +++ b/packfile/objects.go @@ -2,11 +2,9 @@ package packfile import ( "bytes" - "compress/zlib" "crypto/sha1" "encoding/hex" "fmt" - "io/ioutil" "strconv" "time" ) @@ -148,24 +146,13 @@ type TreeEntry struct { Hash string } -func NewTree(b []byte) (*Tree, error) { - o := &Tree{hash: calculateHash("tree", b)} +func NewTree(body []byte) (*Tree, error) { + o := &Tree{hash: calculateHash("tree", body)} - if len(b) == 0 { + if len(body) == 0 { return o, nil } - zr, e := zlib.NewReader(bytes.NewBuffer(b)) - if e == nil { - defer zr.Close() - var err error - b, err = ioutil.ReadAll(zr) - if err != nil { - return nil, err - } - } - - body := b for { split := bytes.SplitN(body, []byte{0}, 2) split1 := bytes.SplitN(split[0], []byte{' '}, 2) |