fix: suppress git stderr when running in non-git directory

This commit is contained in:
weishu
2026-01-12 17:59:52 +08:00
parent b6763a3913
commit 9f2da5f8ae
+5 -1
View File
@@ -86,7 +86,11 @@ function readWorktreeFromGit(): WorktreeInfo | null {
function runGit(args: string[], cwd: string): string | null {
try {
const output = execFileSync('git', args, { cwd, encoding: 'utf8' }).trim();
const output = execFileSync('git', args, {
cwd,
encoding: 'utf8',
stdio: ['ignore', 'pipe', 'ignore']
}).trim();
return output.length > 0 ? output : null;
} catch {
return null;