From 5cfbd8863dfb7c6af92497d9a5eb6eb63a6bd589 Mon Sep 17 00:00:00 2001 From: Runxi Yu Date: Sun, 16 Nov 2025 00:00:00 +0000 Subject: Revert "hash: Generic hash-algorithm API" This reverts commit 94bfb1fa147f80e6ec39009d41fc2f853925e0a5. Generics actually kinda suck for these purposes... once you look at it from the user's perspective. --- obj_blob.go | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) (limited to 'obj_blob.go') diff --git a/obj_blob.go b/obj_blob.go index 1f74464e..9edad0a9 100644 --- a/obj_blob.go +++ b/obj_blob.go @@ -1,26 +1,27 @@ package furgit // Blob represents the contents of a Git blob. -type Blob[T HashType] struct { - Hash Hash[T] +type Blob struct { + Hash Hash + Data []byte } // ObjType allows Blob to satisfy the Object interface. -func (*Blob[T]) ObjType() ObjType { +func (*Blob) ObjType() ObjType { return ObjBlob } -func parseBlob[T HashType](id Hash[T], body []byte) (*Blob[T], error) { +func parseBlob(id Hash, body []byte) (*Blob, error) { data := append([]byte(nil), body...) - return &Blob[T]{ + return &Blob{ Hash: id, Data: data, }, nil } // Serialize renders the full "blob size\\0body" representation. -func (b *Blob[T]) Serialize() ([]byte, error) { +func (b *Blob) Serialize(hashSize int) ([]byte, error) { header, err := headerForType(ObjBlob, b.Data) if err != nil { return nil, err -- cgit v1.3.1-10-gc9f91