MCPcopy Create free account
hub / github.com/colbymchenry/codegraph / readGitExcludeExtraPatterns

Function readGitExcludeExtraPatterns

src/extraction/index.ts:575–602  ·  view source on GitHub ↗

* 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)

Source from the content-addressed store, hash-verified

573 * `git ls-files --exclude-standard` (#1728).
574 */
575function 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

Callers 1

buildDefaultIgnoreFunction · 0.85

Calls 5

resolveGitDirFunction · 0.85
readGitignorePatternsFunction · 0.85
expandUserPathFunction · 0.85
pushMethod · 0.80
joinMethod · 0.45

Tested by

no test coverage detected