MCPcopy Index your code
hub / github.com/colbymchenry/codegraph / gitCommonDir

Function gitCommonDir

src/sync/worktree.ts:54–68  ·  view source on GitHub ↗
(dir: string)

Source from the content-addressed store, hash-verified

52 * from a nested repo the parent index already covers. Null when not a repo.
53 */
54export function gitCommonDir(dir: string): string | null {
55 try {
56 const out = execFileSync('git', ['rev-parse', '--git-common-dir'], {
57 cwd: dir,
58 encoding: 'utf8',
59 stdio: ['ignore', 'pipe', 'ignore'],
60 windowsHide: true,
61 }).trim();
62 if (!out) return null;
63 // `--git-common-dir` is relative to cwd unless already absolute.
64 return realpath(path.isAbsolute(out) ? out : path.resolve(dir, out));
65 } catch {
66 return null;
67 }
68}
69
70export interface WorktreeIndexMismatch {
71 /** The git working tree the command was run from. */

Callers 2

Calls 2

realpathFunction · 0.85
resolveMethod · 0.80

Tested by

no test coverage detected