* Stat .git/index to detect git state changes without spawning git ls-files. * Returns null for worktrees (.git is a file → ENOTDIR), fresh repos with no * index yet (ENOENT), and non-git dirs — caller falls back to time throttle.
()
| 136 | * index yet (ENOENT), and non-git dirs — caller falls back to time throttle. |
| 137 | */ |
| 138 | function getGitIndexMtime(): number | null { |
| 139 | const repoRoot = findGitRoot(getCwd()) |
| 140 | if (!repoRoot) return null |
| 141 | try { |
| 142 | // eslint-disable-next-line custom-rules/no-sync-fs -- mtimeMs is the operation here, not a pre-check. findGitRoot above already stat-walks synchronously; one more stat is marginal vs spawning git ls-files on every keystroke. Async would force startBackgroundCacheRefresh to become async, breaking the synchronous fileListRefreshPromise contract at the cold-start await site. |
| 143 | return statSync(path.join(repoRoot, '.git', 'index')).mtimeMs |
| 144 | } catch { |
| 145 | return null |
| 146 | } |
| 147 | } |
| 148 | |
| 149 | /** |
| 150 | * Normalize git paths relative to originalCwd |
no test coverage detected