* Root-relative exclude patterns from git sources that are NOT the root * `.gitignore`: `.git/info/exclude` and `core.excludesFile`. Same semantics as * the root `.gitignore`, so they merge into buildDefaultIgnore. Without * these, the watcher / FS-walk scope silently diverged from * `gi
(rootDir: string)
| 573 | * `git ls-files --exclude-standard` (#1728). |
| 574 | */ |
| 575 | function readGitExcludeExtraPatterns(rootDir: string): string { |
| 576 | const chunks: string[] = []; |
| 577 | const gitDir = resolveGitDir(rootDir); |
| 578 | if (gitDir) { |
| 579 | const excludePath = path.join(gitDir, 'info', 'exclude'); |
| 580 | if (fs.existsSync(excludePath)) { |
| 581 | const patterns = readGitignorePatterns(excludePath); |
| 582 | if (patterns) chunks.push(patterns); |
| 583 | } |
| 584 | } |
| 585 | try { |
| 586 | const configured = execFileSync( |
| 587 | 'git', |
| 588 | ['-C', rootDir, 'config', '--get', 'core.excludesFile'], |
| 589 | { encoding: 'utf8', timeout: 5_000, stdio: ['ignore', 'pipe', 'ignore'], windowsHide: true }, |
| 590 | ).trim(); |
| 591 | if (configured) { |
| 592 | const abs = expandUserPath(configured); |
| 593 | if (fs.existsSync(abs)) { |
| 594 | const patterns = readGitignorePatterns(abs); |
| 595 | if (patterns) chunks.push(patterns); |
| 596 | } |
| 597 | } |
| 598 | } catch { |
| 599 | // No git, unset, or timeout — leave extras empty. |
| 600 | } |
| 601 | return chunks.join('\n'); |
| 602 | } |
| 603 | |
| 604 | /** |
| 605 | * Directories `git ls-files -o -i --exclude-standard --directory` reports as |
no test coverage detected