(dir: string)
| 30 | * is exactly the distinction this module relies on. |
| 31 | */ |
| 32 | export function gitWorktreeRoot(dir: string): string | null { |
| 33 | try { |
| 34 | const out = execFileSync('git', ['rev-parse', '--show-toplevel'], { |
| 35 | cwd: dir, |
| 36 | encoding: 'utf8', |
| 37 | stdio: ['ignore', 'pipe', 'ignore'], |
| 38 | windowsHide: true, |
| 39 | // Bounded like every git call in extraction/: this runs (memoized) on |
| 40 | // the daemon's main event loop, where an unbounded hang would trip the |
| 41 | // 60s liveness watchdog and SIGKILL a healthy daemon (#1139). |
| 42 | timeout: 5000, |
| 43 | }).trim(); |
| 44 | return out ? realpath(out) : null; |
| 45 | } catch { |
| 46 | return null; |
| 47 | } |
| 48 | } |
| 49 | |
| 50 | /** |
| 51 | * Absolute, symlink-resolved git **common** directory for `dir` — the shared |
no test coverage detected