Skip to content

Commit

Permalink
Skip files in subdirectories when reading git directory
Browse files Browse the repository at this point in the history
  • Loading branch information
MarkKremer committed Aug 27, 2024
1 parent 5a5ee4b commit 1f5eb8d
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion internal/gitfs/gitfs.go
Original file line number Diff line number Diff line change
Expand Up @@ -183,13 +183,18 @@ func (g *GitFile) ReadDir(n int) ([]fs.DirEntry, error) {
var entries []fs.DirEntry
for ; g.pos < c; g.pos++ {
inf := g.filesys.paths[g.pos]
if !strings.HasPrefix(inf.path, filepath.Join(info.path, "/")) {
prefix := info.path + "/"
if !strings.HasPrefix(inf.path, prefix) {
// Done
if len(entries) == 0 {
return nil, io.EOF
}
return entries, nil
}
// Skip files in subdirectories.
if strings.Count(inf.path[len(prefix):], "/") > 0 {
continue
}
entries = append(entries, &GitDirEntry{
filesys: g.filesys,
i: g.pos,
Expand Down

0 comments on commit 1f5eb8d

Please sign in to comment.