diff options
| author | 2025-11-14 00:00:00 +0000 | |
|---|---|---|
| committer | 2025-11-14 00:00:00 +0000 | |
| commit | 9ef659a016d4ffeac931291984a4c71f9527a747 (patch) | |
| tree | 957a76630fe248b638c0a9c84f7acef40a7ee9f5 /obj.go | |
| parent | Initial commit (diff) | |
| signature | ||
Read types and sizes without inflating entire object
Diffstat (limited to 'obj.go')
| -rw-r--r-- | obj.go | 19 |
1 files changed, 19 insertions, 0 deletions
@@ -117,3 +117,22 @@ func (repo *Repository) ReadObject(id Hash) (Object, error) { } return obj, err } + +// ReadObjectTypeSize reports the object type and size without inflating the body. +func (repo *Repository) ReadObjectTypeSize(id Hash) (ObjType, int64, error) { + ty, size, err := repo.looseTypeSize(id) + if err == nil { + return ty, size, nil + } + if !errors.Is(err, ErrNotFound) { + return ObjInvalid, 0, err + } + loc, err := repo.packIndexFind(id) + if err != nil { + if errors.Is(err, ErrNotFound) { + return ObjInvalid, 0, ErrInvalidObject + } + return ObjInvalid, 0, err + } + return repo.packTypeSizeAtLocation(loc, nil) +} |
