* 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.
()
| 305 | * Uses fs.access to check for transient ref files, avoiding process spawns. |
| 306 | */ |
| 307 | async function isInTransientGitState(): Promise<boolean> { |
| 308 | const gitDir = await getGitDir(getCwd()) |
| 309 | if (!gitDir) return false |
| 310 | |
| 311 | const transientFiles = [ |
| 312 | 'MERGE_HEAD', |
| 313 | 'REBASE_HEAD', |
| 314 | 'CHERRY_PICK_HEAD', |
| 315 | 'REVERT_HEAD', |
| 316 | ] |
| 317 | |
| 318 | const results = await Promise.all( |
| 319 | transientFiles.map(file => |
| 320 | access(join(gitDir, file)) |
| 321 | .then(() => true) |
| 322 | .catch(() => false), |
| 323 | ), |
| 324 | ) |
| 325 | return results.some(Boolean) |
| 326 | } |
| 327 | |
| 328 | /** |
| 329 | * Fetch untracked file names (no content reading). |
no test coverage detected