diff options
| author | 2025-11-16 00:00:00 +0000 | |
|---|---|---|
| committer | 2025-11-16 00:00:00 +0000 | |
| commit | edd37bb4fd3aa08eda39303fd5628a554a8c3aeb (patch) | |
| tree | 9b438c2e0b64f880cc57c90446fcec8768e7730b /obj_blob.go | |
| parent | Move config to its own package (diff) | |
| signature | ||
Separate stored object types from types that the user is expected to construct.
Diffstat (limited to 'obj_blob.go')
| -rw-r--r-- | obj_blob.go | 23 |
1 files changed, 17 insertions, 6 deletions
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 } |
