aboutsummaryrefslogtreecommitdiff
path: root/obj_commit.go
diff options
context:
space:
mode:
Diffstat (limited to 'obj_commit.go')
-rw-r--r--obj_commit.go16
1 files changed, 8 insertions, 8 deletions
diff --git a/obj_commit.go b/obj_commit.go
index 84de2c41..9ce52530 100644
--- a/obj_commit.go
+++ b/obj_commit.go
@@ -22,7 +22,7 @@ func (*Commit) ObjType() ObjType {
return ObjCommit
}
-func parseCommit(id Hash, body []byte, hashSize int) (*Commit, error) {
+func parseCommit(id Hash, body []byte, repo *Repository) (*Commit, error) {
c := new(Commit)
c.Hash = id
i := 0
@@ -39,13 +39,13 @@ func parseCommit(id Hash, body []byte, hashSize int) (*Commit, error) {
switch {
case bytes.HasPrefix(line, []byte("tree ")):
- treeID, err := ParseHashWithSize(string(line[5:]), hashSize)
+ treeID, err := repo.ParseHash(string(line[5:]))
if err != nil {
return nil, fmt.Errorf("furgit: commit: tree: %w", err)
}
c.Tree = treeID
case bytes.HasPrefix(line, []byte("parent ")):
- parent, err := ParseHashWithSize(string(line[7:]), hashSize)
+ parent, err := repo.ParseHash(string(line[7:]))
if err != nil {
return nil, fmt.Errorf("furgit: commit: parent: %w", err)
}
@@ -91,11 +91,11 @@ func parseCommit(id Hash, body []byte, hashSize int) (*Commit, error) {
return c, nil
}
-func commitBody(c *Commit, hashSize int) []byte {
+func commitBody(c *Commit) []byte {
var buf bytes.Buffer
- fmt.Fprintf(&buf, "tree %s\n", c.Tree.StringWithSize(hashSize))
+ fmt.Fprintf(&buf, "tree %s\n", c.Tree.String())
for _, p := range c.Parents {
- fmt.Fprintf(&buf, "parent %s\n", p.StringWithSize(hashSize))
+ fmt.Fprintf(&buf, "parent %s\n", p.String())
}
buf.WriteString("author ")
buf.Write(c.Author.Serialize())
@@ -110,8 +110,8 @@ func commitBody(c *Commit, hashSize int) []byte {
}
// Serialize renders a Commit into canonical Git format.
-func (c *Commit) Serialize(hashSize int) ([]byte, error) {
- body := commitBody(c, hashSize)
+func (c *Commit) Serialize() ([]byte, error) {
+ body := commitBody(c)
header, err := headerForType(ObjCommit, body)
if err != nil {
return nil, err