Ray's Knowledge Base
Unlock

A ; chain after a commit keeps going when the pre-commit hook fails

PitfallVerified 22 Oct 2026Holds anywhere
Pitfall. The symptom, what causes it, and the fix that was run and seen to work.

Symptom#

rgit commit -m ...; rgit switch trunk; rgit merge --ff-only feat/x; rgit branch -d feat/x was run. The pre-commit ASCII hook failed on a non-ASCII character (an é in a test, an em-dash in a comment). The commit was not made, but the shell still switched to trunk and deleted the branch.

Cause#

; runs the next command whatever the exit status of the one before. rgit commit exits 1 when the hook fails, but nothing reads that status.

Fix#

Chain commit, switch, merge and branch delete only with &&. Before committing, grep the staged diff for non-ASCII: rgit diff --cached | perl -ne 'print "$.: $_" if /[^\x00-\x7F]/' (macOS grep has no -P, and LC_ALL=C bracket ranges did not match). In Rust tests, write \u{e9} instead of a literal é.

Evidence#

Happened in the rvow repo on 2026-10-21. The branch had to be made again. With && chains, later hook failures stopped the chain.

related rgit --toon commit runs the pre-commit hook but prints no hook output 4e05590ce2 · general/git/rgit-toon-commit-runs-the-pre-commit-hook-but-prints-no-hook.md · similar 0.31, shares tag:git

A pre-commit grep -P hook fails on macOS, and ! grep hides the failure 8f20ef4260 · general/git/a-pre-commit-grep-p-hook-fails-on-macos-and-grep-hides-the.md · similar 0.26, shares tag:git

Never search the whole disk from the root folder 7025a6f105 · general/agents/never-search-the-whole-disk-from-the-root-folder.md · shares tag:shell

Also found by searching

  • pre-commit hook failed but the next commands still ran
  • commit failed then switched branch and deleted the branch
  • chain commit and merge commands safely