Skip to content

diff: pass --no-color so forced git colors do not empty the diff body - #96363

Merged
poteat merged 2 commits into
mainfrom
poteat/diff-no-color
Sep 24, 2026
Merged

poteat merged 2 commits into
mainfrom
poteat/diff-no-color

Conversation

@poteat

@poteat poteat commented Sep 23, 2026

Copy link
Copy Markdown
Contributor

With color.ui=always or color.diff=always in a repository's or a person's git config, every git diff the mod runs answers with ANSI escapes. The header and the per-file counts stay right (they come from --shortstat and --numstat, which git never colors), but no line matches the hunk header pattern any more, so every file's body is empty and the pane shows No diff content under each changed file.

--no-color now rides the shared diff arguments (DIFF_LEADING_ARGS), which every git diff child of the mod spreads (the stats pass, the numstat listing, a file's hunks), so they all answer plain text whatever either setting says. The argv's doc says what the flag pins. The new test in tests/git/fetch-diff.test.ts scripts a colored answer for a body fetch without the flag and a plain one with it, and expects the file's hunk.

Checked:

  • A real temporary repository with color.ui=always, then with color.diff=always, diff.colorMoved=zebra and a custom color.diff.meta: before, /diff from claude --plugin-dir mods/diff shows 2 files changed +2 -1, the two rows with their counts, and No diff content under each; after, each file's hunks. Without either setting the pane reads the same before and after.
  • The new test fails with the argv line reverted (1 of 156) and passes with it.
  • tsc -p mods/tsconfig.json, claude plugin validate mods/diff, git diff --check, and claude plugin test on all four mods (207 tests) under 2.1.277.

Patch by @7487, from #91870.

@poteat
poteat enabled auto-merge (rebase) September 23, 2026 13:39
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.

4 participants