(rootDir: string, sinceCommit?: string | null)
| 1753 | * working-tree diff is the whole of what they wanted. (#1829) |
| 1754 | */ |
| 1755 | export function canTrustGitFastPath(rootDir: string, sinceCommit?: string | null): boolean { |
| 1756 | const head = getGitHeadSha(rootDir); |
| 1757 | if (head == null) return true; // no commits (or not a git repo — caller handles that) |
| 1758 | if (!sinceCommit) return false; |
| 1759 | if (sinceCommit === head) return true; |
| 1760 | try { |
| 1761 | execFileSync('git', ['cat-file', '-e', `${sinceCommit}^{commit}`], { |
| 1762 | cwd: rootDir, encoding: 'utf-8', timeout: 5000, stdio: ['pipe', 'pipe', 'pipe'], windowsHide: true, |
| 1763 | }); |
| 1764 | return true; |
| 1765 | } catch { |
| 1766 | return false; |
| 1767 | } |
| 1768 | } |
| 1769 | |
| 1770 | /** |
| 1771 | * `repoPrefix` is where `repoDir` sits in its repository ({@link gitRepoPrefix}): |
no test coverage detected