From bd91bf5f3bcffe5d1023ab9a37e4a9425830aba9 Mon Sep 17 00:00:00 2001 From: Runxi Yu Date: Sun, 16 Nov 2025 00:00:00 +0000 Subject: hash: Make fewer helper functions need explicit hash length fields --- obj_tag.go | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) (limited to 'obj_tag.go') diff --git a/obj_tag.go b/obj_tag.go index bf9ee97d..dd0dcad0 100644 --- a/obj_tag.go +++ b/obj_tag.go @@ -22,7 +22,7 @@ func (*Tag) ObjType() ObjType { } // parseTag parses a tag object body. -func parseTag(id Hash, body []byte, hashSize int) (*Tag, error) { +func parseTag(id Hash, body []byte, repo *Repository) (*Tag, error) { t := new(Tag) t.Hash = id i := 0 @@ -41,7 +41,7 @@ func parseTag(id Hash, body []byte, hashSize int) (*Tag, error) { switch { case bytes.HasPrefix(line, []byte("object ")): - hash, err := ParseHashWithSize(string(line[7:]), hashSize) + hash, err := repo.ParseHash(string(line[7:])) if err != nil { return nil, fmt.Errorf("furgit: tag: object: %w", err) } @@ -94,9 +94,9 @@ func parseTag(id Hash, body []byte, hashSize int) (*Tag, error) { return t, nil } -func tagBody(t *Tag, hashSize int) ([]byte, error) { +func tagBody(t *Tag) ([]byte, error) { var buf bytes.Buffer - fmt.Fprintf(&buf, "object %s\n", t.Target.StringWithSize(hashSize)) + fmt.Fprintf(&buf, "object %s\n", t.Target.String()) buf.WriteString("type ") switch t.TargetType { case ObjCommit: @@ -128,8 +128,8 @@ func tagBody(t *Tag, hashSize int) ([]byte, error) { } // Serialize renders a Tag into canonical Git format. -func (t *Tag) Serialize(hashSize int) ([]byte, error) { - body, err := tagBody(t, hashSize) +func (t *Tag) Serialize() ([]byte, error) { + body, err := tagBody(t) if err != nil { return nil, err } -- cgit v1.3.1-10-gc9f91