From ec658d86dda3ac0e9b63635a4144c432223b9fc8 Mon Sep 17 00:00:00 2001 From: Runxi Yu Date: Sun, 29 Mar 2026 09:49:21 +0000 Subject: object: Split files --- object/parse_without_header.go | 32 ++++++++++++++++++++++++++++++++ 1 file changed, 32 insertions(+) create mode 100644 object/parse_without_header.go (limited to 'object/parse_without_header.go') diff --git a/object/parse_without_header.go b/object/parse_without_header.go new file mode 100644 index 00000000..d8774b9a --- /dev/null +++ b/object/parse_without_header.go @@ -0,0 +1,32 @@ +package object + +import ( + "fmt" + + "codeberg.org/lindenii/furgit/object/blob" + "codeberg.org/lindenii/furgit/object/commit" + objectid "codeberg.org/lindenii/furgit/object/id" + "codeberg.org/lindenii/furgit/object/tag" + "codeberg.org/lindenii/furgit/object/tree" + objecttype "codeberg.org/lindenii/furgit/object/type" +) + +// ParseObjectWithoutHeader parses a typed object body. +// +//nolint:ireturn +func ParseObjectWithoutHeader(ty objecttype.Type, body []byte, algo objectid.Algorithm) (Object, error) { + switch ty { + case objecttype.TypeBlob: + return blob.Parse(body) + case objecttype.TypeTree: + return tree.Parse(body, algo) + case objecttype.TypeCommit: + return commit.Parse(body, algo) + case objecttype.TypeTag: + return tag.Parse(body, algo) + case objecttype.TypeInvalid, objecttype.TypeFuture, objecttype.TypeOfsDelta, objecttype.TypeRefDelta: + return nil, fmt.Errorf("object: unsupported object type %d", ty) + default: + return nil, fmt.Errorf("object: unsupported object type %d", ty) + } +} -- cgit v1.3.1-10-gc9f91