aboutsummaryrefslogtreecommitdiff
path: root/object/fetch/exact_blob.go
diff options
context:
space:
mode:
authorGravatar Runxi Yu2026-03-25 19:33:32 +0000
committerGravatar Runxi Yu2026-03-25 19:33:57 +0000
commit1aa5cad4c8d6455eeb1f10893549e18bcca11996 (patch)
tree31082a30bde08639fc764c52c3cf2283489f3302 /object/fetch/exact_blob.go
parentTODO: updates (diff)
signatureNo signature
object/fetch: Rename from object/resolve
Diffstat (limited to 'object/fetch/exact_blob.go')
-rw-r--r--object/fetch/exact_blob.go24
1 files changed, 24 insertions, 0 deletions
diff --git a/object/fetch/exact_blob.go b/object/fetch/exact_blob.go
new file mode 100644
index 00000000..96ededdc
--- /dev/null
+++ b/object/fetch/exact_blob.go
@@ -0,0 +1,24 @@
+package fetch
+
+import (
+ "fmt"
+
+ "codeberg.org/lindenii/furgit/object/blob"
+ objectid "codeberg.org/lindenii/furgit/object/id"
+ "codeberg.org/lindenii/furgit/object/stored"
+)
+
+// ExactBlob reads, parses, and wraps the blob at id.
+func (r *Fetcher) ExactBlob(id objectid.ObjectID) (*stored.Stored[*blob.Blob], error) {
+ parsed, err := r.parseObject(id)
+ if err != nil {
+ return nil, err
+ }
+
+ blob, ok := parsed.(*blob.Blob)
+ if !ok {
+ return nil, fmt.Errorf("object/fetch: expected blob object %s, got %v", id, parsed.ObjectType())
+ }
+
+ return stored.New(id, blob), nil
+}