From edd37bb4fd3aa08eda39303fd5628a554a8c3aeb Mon Sep 17 00:00:00 2001 From: Runxi Yu Date: Sun, 16 Nov 2025 00:00:00 +0000 Subject: Separate stored object types from types that the user is expected to construct. --- obj_blob.go | 23 +++++++++++++++++------ 1 file changed, 17 insertions(+), 6 deletions(-) (limited to 'obj_blob.go') diff --git a/obj_blob.go b/obj_blob.go index c25f88eb..6a987604 100644 --- a/obj_blob.go +++ b/obj_blob.go @@ -2,22 +2,33 @@ package furgit // Blob represents the contents of a Git blob. type Blob struct { - Hash Hash - Data []byte } +// StoredBlob represents a blob stored in the object database. +type StoredBlob struct { + Blob + hash Hash +} + +// Hash returns the hash of the stored blob. +func (sBlob *StoredBlob) Hash() Hash { + return sBlob.hash +} + // ObjectType allows Blob to satisfy the Object interface. func (blob *Blob) ObjectType() ObjectType { _ = blob return ObjectTypeBlob } -func parseBlob(id Hash, body []byte) (*Blob, error) { +func parseBlob(id Hash, body []byte) (*StoredBlob, error) { data := append([]byte(nil), body...) - return &Blob{ - Hash: id, - Data: data, + return &StoredBlob{ + hash: id, + Blob: Blob{ + Data: data, + }, }, nil } -- cgit v1.3.1-10-gc9f91