diff options
| author | 2026-03-04 08:26:56 +0800 | |
|---|---|---|
| committer | 2026-03-04 08:59:53 +0800 | |
| commit | ab7501be34032fb9e5c48726a68ae90a917af9eb (patch) | |
| tree | 20d005647569befea8133e953c3270e8fd2a2a5b /object/tree_parse.go | |
| parent | *: gofumpt (diff) | |
| signature | No signature | |
*: Lint
Diffstat (limited to 'object/tree_parse.go')
| -rw-r--r-- | object/tree_parse.go | 5 |
1 files changed, 5 insertions, 0 deletions
diff --git a/object/tree_parse.go b/object/tree_parse.go index 37a2fa4b..dd4faa8b 100644 --- a/object/tree_parse.go +++ b/object/tree_parse.go @@ -11,12 +11,14 @@ import ( // ParseTree decodes a tree object body. func ParseTree(body []byte, algo objectid.Algorithm) (*Tree, error) { var entries []TreeEntry + i := 0 for i < len(body) { space := bytes.IndexByte(body[i:], ' ') if space < 0 { return nil, fmt.Errorf("object: tree: missing mode terminator") } + modeBytes := body[i : i+space] i += space + 1 @@ -24,6 +26,7 @@ func ParseTree(body []byte, algo objectid.Algorithm) (*Tree, error) { if nul < 0 { return nil, fmt.Errorf("object: tree: missing name terminator") } + nameBytes := body[i : i+nul] i += nul + 1 @@ -31,10 +34,12 @@ func ParseTree(body []byte, algo objectid.Algorithm) (*Tree, error) { if idEnd > len(body) { return nil, fmt.Errorf("object: tree: truncated child object id") } + id, err := objectid.FromBytes(algo, body[i:idEnd]) if err != nil { return nil, err } + i = idEnd mode, err := strconv.ParseUint(string(modeBytes), 8, 32) |
