Summary
When a project root contains nested .git directories (monorepos, git submodules, git subtrees), FileIndexer does not detect or handle them. The scanner will index files from nested repos that should be boundary-excluded, creating cross-repo symbol references that are semantically invalid. The .git directory is only skipped via hardcoded SkipDirs (line 328), but nested .git directories inside indexed subtrees are not boundary-detected during traversal.
Where
src/CodeIndex/Indexer/Scanning/FileIndexer.cs:328 (SkipDirs includes ".git" but nested repos not checked)
src/CodeIndex/Indexer/Scanning/FileIndexer.cs:1484 (ScanDirectory recursively traverses without repo-boundary detection)
src/CodeIndex/Cli/IndexCommandRunner.cs:95 (ignoreRuleRoot uses single TryGetRepositoryRoot call, not per-subtree detection)
Suggested approach
- Add an optional
detectNestedRepos mode to FileIndexer constructor
- During ScanDirectory (line 1484), probe for nested
.git directories before recursing into subdirectories
- When a nested
.git is detected, treat it as a boundary and either skip the subtree or flag it in ScanFilesResult for warning
- Store nested repo boundaries in IndexCommandRunner to emit warnings and optionally exclude from indexing
- Extend ScanFilesResult with a
NestedRepositories field documenting detected monorepo/submodule boundaries
- Add a
--include-nested-repos CLI flag for users who want cross-repo indexing (documented as unsupported)
Summary
When a project root contains nested .git directories (monorepos, git submodules, git subtrees), FileIndexer does not detect or handle them. The scanner will index files from nested repos that should be boundary-excluded, creating cross-repo symbol references that are semantically invalid. The
.gitdirectory is only skipped via hardcoded SkipDirs (line 328), but nested.gitdirectories inside indexed subtrees are not boundary-detected during traversal.Where
src/CodeIndex/Indexer/Scanning/FileIndexer.cs:328(SkipDirs includes ".git" but nested repos not checked)src/CodeIndex/Indexer/Scanning/FileIndexer.cs:1484(ScanDirectory recursively traverses without repo-boundary detection)src/CodeIndex/Cli/IndexCommandRunner.cs:95(ignoreRuleRoot uses single TryGetRepositoryRoot call, not per-subtree detection)Suggested approach
detectNestedReposmode to FileIndexer constructor.gitdirectories before recursing into subdirectories.gitis detected, treat it as a boundary and either skip the subtree or flag it in ScanFilesResult for warningNestedRepositoriesfield documenting detected monorepo/submodule boundaries--include-nested-reposCLI flag for users who want cross-repo indexing (documented as unsupported)