aboutsummaryrefslogtreecommitdiff
path: root/pack_pack.go
diff options
context:
space:
mode:
authorGravatar Runxi Yu2025-11-22 08:00:00 +0800
committerGravatar Runxi Yu2025-11-22 08:00:00 +0800
commit8aa544539d452f310b6a88348f2a50bda017e317 (patch)
tree6dd059c709853c4296ea8fd837857a8a92bcb497 /pack_pack.go
parentpack: Allocate the header on the stack instead (diff)
signatureNo signature
obj: call parseObjectBody in ReadObject instead of loose/pack readers
Diffstat (limited to 'pack_pack.go')
-rw-r--r--pack_pack.go17
1 files changed, 7 insertions, 10 deletions
diff --git a/pack_pack.go b/pack_pack.go
index 1b98bcca..c7910462 100644
--- a/pack_pack.go
+++ b/pack_pack.go
@@ -22,10 +22,10 @@ type packlocation struct {
Offset uint64
}
-func (repo *Repository) packRead(id Hash) (StoredObject, error) {
+func (repo *Repository) packRead(id Hash) (ObjectType, *bufpool.Buffer, error) {
loc, err := repo.packIndexFind(id)
if err != nil {
- return nil, err
+ return ObjectTypeInvalid, nil, err
}
return repo.packReadAt(loc, id)
}
@@ -48,19 +48,16 @@ func (repo *Repository) packIndexFind(id Hash) (packlocation, error) {
return packlocation{}, ErrNotFound
}
-func (repo *Repository) packReadAt(loc packlocation, want Hash) (StoredObject, error) {
+func (repo *Repository) packReadAt(loc packlocation, want Hash) (ObjectType, *bufpool.Buffer, error) {
ty, body, err := repo.packBodyResolveAtLocation(loc)
if err != nil {
- return nil, err
+ return ObjectTypeInvalid, nil, err
}
- data := body.Bytes()
- // if !repo.verifyTypedObject(ty, data, want) {
+ // if !repo.verifyTypedObject(ty, body.Bytes(), want) {
// body.Release()
- // return nil, ErrInvalidObject
+ // return ObjectTypeInvalid, nil, ErrInvalidObject
// }
- obj, err := parseObjectBody(ty, want, data, repo)
- body.Release()
- return obj, err
+ return ty, body, nil
}
func (repo *Repository) packBodyResolveAtLocation(loc packlocation) (ObjectType, *bufpool.Buffer, error) {