Skip to content

Nested .git repositories inside project root indexed without boundary detection #2022

Description

@Widthdom

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

  1. Add an optional detectNestedRepos mode to FileIndexer constructor
  2. During ScanDirectory (line 1484), probe for nested .git directories before recursing into subdirectories
  3. When a nested .git is detected, treat it as a boundary and either skip the subtree or flag it in ScanFilesResult for warning
  4. Store nested repo boundaries in IndexCommandRunner to emit warnings and optionally exclude from indexing
  5. Extend ScanFilesResult with a NestedRepositories field documenting detected monorepo/submodule boundaries
  6. Add a --include-nested-repos CLI flag for users who want cross-repo indexing (documented as unsupported)

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions