Skip to content

Fix briefing_git() leaking a system2 status-128 warning on non-repos - #34

Merged
TroyHernandez merged 3 commits into
mainfrom
fix/briefing-git-warning-leak
Jun 7, 2026
Merged

TroyHernandez merged 3 commits into
mainfrom
fix/briefing-git-warning-leak

Conversation

@TroyHernandez

Copy link
Copy Markdown
Contributor

Closes #33.

briefing_git() prechecked the repo with dir.exists(file.path(repo_dir, ".git")), which passes in cases where git log then fails with a non-zero exit: git worktrees (.git is a file, not a directory), invalid/empty .git dirs, and dubious-ownership states. system2() raises a simpleWarning ("had status 128") on non-zero exit, and the surrounding tryCatch only handled error, so the warning leaked to the user.

It surfaced via corteza's load_saber_briefing() at chat() setup when run in a non-git directory.

Changes

  • Replace the dir.exists(".git") precheck with git rev-parse --is-inside-work-tree, which correctly reports non-repos (including worktrees) before we run git log.
  • Wrap both system2() calls in suppressWarnings() so a non-zero exit returns empty silently instead of leaking a "had status N" warning past the best-effort helper.

Tests

Two regression tests in test_briefing.R:

  • A directory with an invalid .git (passes dir.exists, fails git log) returns character(0) with no warning.
  • A plain non-git directory likewise stays silent and empty.

Full suite: 169 pass, 0 fail.

briefing_git() prechecked with dir.exists(".git"), which passes for
worktrees (where .git is a file), invalid .git dirs, and dubious-
ownership cases where git still exits non-zero. The resulting "had
status 128" warning from system2() propagated past the error-only
tryCatch and leaked to the user (e.g. corteza's load_saber_briefing()
in a non-git directory).

Replace the precheck with 'git rev-parse --is-inside-work-tree' and
wrap both system2() calls in suppressWarnings(), so this best-effort
helper stays silent and returns character(0) when git can't read the
repo. Fixes #33.
@TroyHernandez
TroyHernandez merged commit 8739e22 into main Jun 7, 2026
4 checks passed
@TroyHernandez
TroyHernandez deleted the fix/briefing-git-warning-leak branch June 7, 2026 03:31
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.

briefing_git() leaks system2 'status 128' warning when git fails

1 participant