* Check if we're in a transient git state (merge, rebase, cherry-pick, or revert). * During these operations, we skip diff calculation since the working * tree contains incoming changes that weren't intentionally made. * * Uses fs.access to check for transient ref files, avoiding process spawns.
()
| 307 | * Uses fs.access to check for transient ref files, avoiding process spawns. |
| 308 | */ |
| 309 | async function isInTransientGitState(): Promise<boolean> { |
| 310 | const gitDir = await getGitDir(getCwd()) |
| 311 | if (!gitDir) return false |
| 312 | |
| 313 | const transientFiles = [ |
| 314 | 'MERGE_HEAD', |
| 315 | 'REBASE_HEAD', |
| 316 | 'CHERRY_PICK_HEAD', |
| 317 | 'REVERT_HEAD', |
| 318 | ] |
| 319 | |
| 320 | const results = await Promise.all( |
| 321 | transientFiles.map(file => |
| 322 | access(join(gitDir, file)) |
| 323 | .then(() => true) |
| 324 | .catch(() => false), |
| 325 | ), |
| 326 | ) |
| 327 | return results.some(Boolean) |
| 328 | } |
| 329 | |
| 330 | /** |
| 331 | * Fetch untracked file names (no content reading). |
no test coverage detected