Repository navigation
fix(review): keep git and jj output color-free under color.diff=always (#1661) - #1662
Merged
Merged
Conversation
#1661) A user config with color.diff = always (or jj ui.color = "always") colored every piped diff, so the patch parser found 0 files and viewed-file identity capture found 0 identities. color.ui=never alone does not override an explicit color.diff, so prepareGitCommand now sets each color key to never plus --no-pager, in both runtimes. jj runtimes add --color=never --no-pager, gh pr diff gets --color=never, agent jobs inherit the same git settings via GIT_CONFIG_*, and parseDiffToFiles strips ANSI codes from a patch whose headers are colored as a backstop. Reported by @sholsinger.
backnotprop
added a commit
that referenced
this pull request
Oct 2, 2026
CallDiff runs git itself and inherited process.env without the color-free GIT_CONFIG_* entries, so a user's color.diff = always could still break Call Flow analysis after #1662. Both worker spawns now carry gitColorFreeEnvironment.
1 task
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixes #1661. Thanks to @sholsinger for the report and for tracing it to the colorized
/api/diffpayload.Root cause
Plannotator ran git with no color override. With
color.diff = alwaysin the user's git config, every piped diff line came back wrapped in ANSI escapes. The parser matches^diff --git, so it found 0 files, and viewed-file identity capture (--raw --patch) found 0 identities.-c color.ui=neveralone does not fix it: the specificcolor.diffkey wins overcolor.ui(checked on git 2.50). jj has the same problem withui.color = "always".Fix
prepareGitCommand(the one runner every review git call uses, Bun and Pi) now prepends--no-pager -c color.ui=never -c color.diff=never -c color.status=never -c color.branch=never -c color.grep=never -c color.showBranch=never -c color.interactive=never. This covers the review diff, file identities, since-base sections, the Commits panel, generated files, hunk expansion, image previews, GitButler's git calls, and PR worktrees.runJj/runJjBytesadd--color=never --no-pager(JJ_COLOR_FREE_ARGS).gh pr diff:--color=never, soCLICOLOR_FORCE/GH_FORCE_TTYcannot color it.GIT_CONFIG_*variables, so thegit diffit runs itself stays plain.parseDiffToFilesstrips ANSI codes only when the patch's owndiff --githeaders are colored (for example, a colorized--patch-file). A normal patch, including one whose content contains escape bytes, is returned byte for byte, so patch bytes and draft keys do not change.Checked and left alone: ripgrep code-nav uses
--json, which is never colored, even with--color=alwaysinRIPGREP_CONFIG_PATH. The annotate file browser runs onlystatus --porcelainanddiff --numstat, which git never colors. GitButler'sbutcalls use JSON output. P4 has no color.Evidence
The real
plannotator reviewserver ran on a temp repo with a sandboxedGIT_CONFIG_GLOBAL(color.ui/diff/status/branch=always,diff.noprefix,core.pager,pager.diff=true):rawPatcha.txt +1/-1, b.txt +1/-0, c.txt +1/-0, d.txt +1/-0{}/api/commits/api/file-contentui.color="always") filesb.txt, d.txtTests
packages/server/review-git-color-config.test.ts: runs both servers (Bun and Pi) against a sandboxed hostile config, using a tempGIT_CONFIG_GLOBAL/JJ_CONFIG, so the real config is never touched. It checks the files and their +/- counts, identities, since-base sections, Commits history, and file expansion. It also checks the jj diff in both runtimes (skipped without jj) and the agent-job environment. A guard test asserts that the sandbox really colors a pipedgit diff. With the fix reverted, the Bun/Pi git tests and both jj tests fail.packages/core/diff-files.test.ts: a colorized patch parses, and a plain patch with escape bytes in its content is unchanged.review-core.test.ts: the argv expectations now include the new prefix.bun run typecheckis clean. The fullbun testrun passes, except 2 entry-asset tests that readapps/hook/dist, which was not built locally.