aboutsummaryrefslogtreecommitdiff
path: root/obj.go
diff options
context:
space:
mode:
authorGravatar Runxi Yu2025-11-16 00:00:00 +0000
committerGravatar Runxi Yu2025-11-16 00:00:00 +0000
commitedd37bb4fd3aa08eda39303fd5628a554a8c3aeb (patch)
tree9b438c2e0b64f880cc57c90446fcec8768e7730b /obj.go
parentMove config to its own package (diff)
signature
Separate stored object types from types that the user is expected to construct.
Diffstat (limited to 'obj.go')
-rw-r--r--obj.go8
1 files changed, 7 insertions, 1 deletions
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)