* Use `git status` to detect changed files instead of scanning every file. * Returns null on failure so callers fall back to full scan. * * Recurses into embedded repos — the untracked kind (#193: the parent's status * collapses them to an opaque `?? subdir/` entry) always, and the gitignored *
(rootDir: string)
| 831 | * with it); a full `codegraph index` reconciles that. |
| 832 | */ |
| 833 | function getGitChangedFiles(rootDir: string): GitChanges | null { |
| 834 | try { |
| 835 | const changes: GitChanges = { modified: [], added: [], deleted: [] }; |
| 836 | // Custom extension → language overrides from the project's codegraph.json, |
| 837 | // so change detection sees the same custom-extension files the full index does. |
| 838 | const overrides = loadExtensionOverrides(rootDir); |
| 839 | collectGitStatus(rootDir, '', changes, overrides, loadIncludeIgnoredMatcher(rootDir), loadExcludeMatcher(rootDir)); |
| 840 | return changes; |
| 841 | } catch { |
| 842 | return null; |
| 843 | } |
| 844 | } |
| 845 | |
| 846 | function collectGitStatus(repoDir: string, prefix: string, out: GitChanges, overrides?: Record<string, Language>, includeIgnored: Ignore | null = null, exclude: Ignore | null = null): void { |
| 847 | const output = execFileSync( |
no test coverage detected