aboutsummaryrefslogtreecommitdiff
path: root/obj_blob.go
diff options
context:
space:
mode:
Diffstat (limited to 'obj_blob.go')
-rw-r--r--obj_blob.go23
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
}