Skip to content

Silence git stderr in non-repository folders (fixes 'fatal: not a git repository' noise) - #2

Merged
hypnguyen1209 merged 1 commit into
pifydev:mainfrom
D3mianGianoz:suppress-git-stderr-in-non-repo
Nov 2, 2026
Merged

hypnguyen1209 merged 1 commit into
pifydev:mainfrom
D3mianGianoz:suppress-git-stderr-in-non-repo

Conversation

@D3mianGianoz

Copy link
Copy Markdown

When working in a folder that is not a git repository, yolo prints git fatal messages on every risky bash/powershell command and on /yolo rewind:

fatal: not a git repository (or any of the parent directories): .git

The extension already handles these failures internally (gitHead returns null, decideCheckpoint returns {failed:true}), but execFileSync("git", ...) uses the default stdio, so git's stderr leaks to the terminal. It is noise, not a functional issue — commands still behave per mode and the trail still logs.

Fix: pass stdio: ["ignore", "pipe", "ignore"] to the 5 execFileSync("git", ...) calls in extensions/yolo.ts (gitHead, gitCheckpoint runGit/update-ref, releaseRefs, /yolo rewind restore). Stdout keeps working; only stderr is silenced.

Related issue: #1

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.

@hypnguyen1209 hypnguyen1209 left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Approved. Correct and complete: the issue is cosmetic (yolo already handles the failures — gitHead returns null, decideCheckpoint returns {failed:true}), it is only git's stderr leaking, and stdio: ["ignore", "pipe", "ignore"] silences stderr while keeping stdout for the calls that read it (rev-parse HEAD, the checkpoint runGit). I confirmed all five execFileSync("git", …) sites in extensions/yolo.ts are covered — rev-parse, the checkpoint runGit and update-ref, releaseRefs' update-ref, and the /yolo rewind restore — and there are no other git spawns that could leak. Merged onto current main (0.16.1): clean, tsc --noEmit passes, 135 tests green. Thanks!

@hypnguyen1209
hypnguyen1209 merged commit 7c6b997 into pifydev:main Nov 2, 2026
2 checks passed
hypnguyen1209 added a commit that referenced this pull request Nov 2, 2026
Ships the community fix from #2 (by @D3mianGianoz): the five
execFileSync("git", …) calls now pass stdio: ["ignore", "pipe",
"ignore"], so git's "fatal: not a git repository" no longer leaks to the
terminal on every risky command or /yolo rewind when the cwd is not a
repo. yolo already handled the failures internally; this only silences
the noise. Stdout is kept for the calls that read it.
@D3mianGianoz
D3mianGianoz deleted the suppress-git-stderr-in-non-repo branch November 3, 2026 15:49
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants