From ca8e2e5ed7618fa3cded2d57a2d99ccd45e951b2 Mon Sep 17 00:00:00 2001 From: D3mianGianoz Date: Wed, 7 Oct 2026 11:21:42 +0200 Subject: [PATCH] suppress git stderr when cwd is not a repository When the working folder is not a git repository, git calls (rev-parse, stash create, update-ref) printed 'fatal: not a git repository' to the terminal on every risky command and on /yolo rewind. The errors are already caught internally, but their stderr leaked through. Pass stdio: ["ignore", "pipe", "ignore"] to the 5 execFileSync("git", ...) calls. Behavior in repos is unchanged; in non-repos the git ops fail silently instead of printing. --- extensions/yolo.ts | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/extensions/yolo.ts b/extensions/yolo.ts index 11ee0df..fa879c1 100644 --- a/extensions/yolo.ts +++ b/extensions/yolo.ts @@ -142,6 +142,7 @@ export default function yolo(pi: ExtensionAPI) { encoding: "utf8", timeout: 2000, windowsHide: true, + stdio: ["ignore", "pipe", "ignore"], }).trim(); } catch { return null; @@ -158,7 +159,7 @@ export default function yolo(pi: ExtensionAPI) { */ function gitCheckpoint(cwd: string, now: number): CheckpointResult { const runGit = (args: string[]): string => - execFileSync("git", args, { cwd, encoding: "utf8", timeout: 5000, windowsHide: true }).toString(); + execFileSync("git", args, { cwd, encoding: "utf8", timeout: 5000, windowsHide: true, stdio: ["ignore", "pipe", "ignore"] }).toString(); const result = decideCheckpoint(runGit); if ("sha" in result) { try { @@ -166,6 +167,7 @@ export default function yolo(pi: ExtensionAPI) { cwd, timeout: 5000, windowsHide: true, + stdio: ["ignore", "pipe", "ignore"], }); } catch { // unreachable-but-recent commits still survive the default gc window @@ -381,7 +383,7 @@ Go ahead anyway?`)); function releaseRefs(cwd: string, refs: string[]): void { for (const ref of refs) { try { - execFileSync("git", ["update-ref", "-d", ref], { cwd, timeout: 5000, windowsHide: true }); + execFileSync("git", ["update-ref", "-d", ref], { cwd, timeout: 5000, windowsHide: true, stdio: ["ignore", "pipe", "ignore"] }); } catch { // already gone, or not a repo any more } @@ -926,6 +928,7 @@ Go ahead anyway?`)); cwd: ctx.cwd, timeout: 30_000, windowsHide: true, + stdio: ["ignore", "pipe", "ignore"], }); ctx.ui.notify(`Working tree restored to ${point.treeSha?.slice(0, 8)}.`, "info"); } catch (err) {