Skip to content

Commit 1f5eb8d

Browse files
committed
Skip files in subdirectories when reading git directory
1 parent 5a5ee4b commit 1f5eb8d

File tree

1 file changed

+6
-1
lines changed

1 file changed

+6
-1
lines changed

internal/gitfs/gitfs.go

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -183,13 +183,18 @@ func (g *GitFile) ReadDir(n int) ([]fs.DirEntry, error) {
183183
var entries []fs.DirEntry
184184
for ; g.pos < c; g.pos++ {
185185
inf := g.filesys.paths[g.pos]
186-
if !strings.HasPrefix(inf.path, filepath.Join(info.path, "/")) {
186+
prefix := info.path + "/"
187+
if !strings.HasPrefix(inf.path, prefix) {
187188
// Done
188189
if len(entries) == 0 {
189190
return nil, io.EOF
190191
}
191192
return entries, nil
192193
}
194+
// Skip files in subdirectories.
195+
if strings.Count(inf.path[len(prefix):], "/") > 0 {
196+
continue
197+
}
193198
entries = append(entries, &GitDirEntry{
194199
filesys: g.filesys,
195200
i: g.pos,

0 commit comments

Comments
 (0)