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

Function gitCommonDir

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

Source from the content-addressed store, hash-verified

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

Calls 2

realpathFunction · 0.85
resolveMethod · 0.80

Tested by

no test coverage detected