diff --git a/walk/filesystem.go b/walk/filesystem.go index 729a4972..55973ced 100644 --- a/walk/filesystem.go +++ b/walk/filesystem.go @@ -19,11 +19,6 @@ func (f filesystemWalker) Root() string { } func (f filesystemWalker) relPath(path string) (string, error) { - // quick optimization for the majority of use cases - if len(path) >= f.relPathOffset && path[:len(f.root)] == f.root { - return path[f.relPathOffset:], nil - } - // fallback to proper relative path resolution return filepath.Rel(f.root, path) } diff --git a/walk/git.go b/walk/git.go index cfd56c4b..4e3c6505 100644 --- a/walk/git.go +++ b/walk/git.go @@ -3,14 +3,15 @@ package walk import ( "context" "fmt" - "github.com/charmbracelet/log" - "github.com/go-git/go-git/v5/plumbing/filemode" - "github.com/go-git/go-git/v5/plumbing/format/index" "io/fs" "os" "path/filepath" "strings" + "github.com/charmbracelet/log" + "github.com/go-git/go-git/v5/plumbing/filemode" + "github.com/go-git/go-git/v5/plumbing/format/index" + "github.com/go-git/go-git/v5" ) @@ -95,7 +96,6 @@ func (g gitWalker) Walk(ctx context.Context, fn WalkFunc) error { var cache *fileTree for path := range g.paths { - switch path { case g.root: diff --git a/walk/git_test.go b/walk/git_test.go index 811fccf0..e557eae3 100644 --- a/walk/git_test.go +++ b/walk/git_test.go @@ -1,12 +1,12 @@ package walk import ( - "github.com/stretchr/testify/require" "testing" + + "github.com/stretchr/testify/require" ) func TestFileTree(t *testing.T) { - as := require.New(t) node := &fileTree{name: ""}