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.go | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) (limited to 'obj.go') diff --git a/obj.go b/obj.go index de847607..ee11a024 100644 --- a/obj.go +++ b/obj.go @@ -33,6 +33,12 @@ type Object interface { ObjectType() ObjectType } +// StoredObject describes a Git object with a known hash. +type StoredObject interface { + Object + Hash() Hash +} + func headerForType(ty ObjectType, body []byte) ([]byte, error) { var tyStr string switch ty { @@ -59,7 +65,7 @@ func headerForType(ty ObjectType, body []byte) ([]byte, error) { return buf.Bytes(), nil } -func parseObjectBody(ty ObjectType, id Hash, body []byte, repo *Repository) (Object, error) { +func parseObjectBody(ty ObjectType, id Hash, body []byte, repo *Repository) (StoredObject, error) { switch ty { case ObjectTypeBlob: return parseBlob(id, body) -- cgit v1.3.1-10-gc9f91