aboutsummaryrefslogtreecommitdiff
path: root/object/fetch
diff options
context:
space:
mode:
authorGravatar Runxi Yu2026-06-13 16:34:25 +0000
committerGravatar Runxi Yu2026-06-13 16:37:10 +0000
commit9ec139fbff856e9f056a4e5efeafb648ec0b7d26 (patch)
tree6680836f6531259a99cc66dc28df91538ef5c1e7 /object/fetch
parentobject/tree: Fix tests again (diff)
object/fetch: Fix API shape
Diffstat (limited to 'object/fetch')
-rw-r--r--object/fetch/path.go2
-rw-r--r--object/fetch/treefs.go10
2 files changed, 6 insertions, 6 deletions
diff --git a/object/fetch/path.go b/object/fetch/path.go
index f8eca507..e8b12481 100644
--- a/object/fetch/path.go
+++ b/object/fetch/path.go
@@ -47,7 +47,7 @@ func (err *PathNotTreeError) Error() string {
// for an io/fs.FS-like interface.
//
// Labels: Life-Parent.
-func (fetcher *Fetcher) Path(root oid.ObjectID, parts []string) (tree.Entry, error) {
+func (fetcher *Fetcher) Path(root oid.ObjectID, parts [][]byte) (tree.Entry, error) {
if len(parts) == 0 {
return tree.Entry{}, ErrPathInvalid
}
diff --git a/object/fetch/treefs.go b/object/fetch/treefs.go
index 9d88abb2..d12e3dd6 100644
--- a/object/fetch/treefs.go
+++ b/object/fetch/treefs.go
@@ -1,11 +1,11 @@
package fetch
import (
+ "bytes"
"errors"
"fmt"
"io"
"io/fs"
- "strings"
"time"
oid "lindenii.org/go/furgit/object/id"
@@ -48,12 +48,12 @@ var ErrGitlinkNotFile = fmt.Errorf("%w: object/fetch: gitlink entries are not re
// generic fs consumers classify it correctly.
var ErrIsDirectory = fmt.Errorf("%w: object/fetch: is a directory", fs.ErrInvalid)
-func splitPath(path string) []string {
+func splitPath(path string) [][]byte {
if len(path) == 0 {
return nil
}
- return strings.Split(path, "/")
+ return bytes.Split([]byte(path), []byte("/"))
}
type treeEntryValue struct {
@@ -197,7 +197,7 @@ func (treeFS *TreeFS) Open(name string) (fs.File, error) {
entries := make([]fs.DirEntry, 0, len(tree.Object().Entries()))
for _, child := range tree.Object().Entries() {
childEntry := treeEntryValue{
- name: child.Name,
+ name: string(child.Name),
mode: child.Mode,
objectID: child.ID,
treeEntry: &child,
@@ -401,7 +401,7 @@ func (treeFS *TreeFS) resolvePath(op treeFSOp, name string) (treeEntryValue, err
}
return treeEntryValue{
- name: entry.Name,
+ name: string(entry.Name),
mode: entry.Mode,
objectID: entry.ID,
treeEntry: &entry,