spacehub

surshar / claude-code

Claude Code is an agentic coding tool that lives in your terminal, understands your codebase, and helps you code faster by executing routine tasks, explaining complex code, and handling git workflows - all through natural language commands.

Built by Anthropic · github.com/anthropics

fix(diff): preserve hunks when Git forces colored outputBrowse files
7487 authored on Sep 21, 2026 · Alice T'Poteat committed 28 days ago parent cbab6f4 · commit 453620980b70
2 changed files+37 -0compared with cbab6f4
Mmods/diff/hooks/git/argv/diff-leading-args.ts
Mmods/diff/tests/git/fetch-diff.test.ts
@@ -13,6 +13,7 @@
1313 '-c',
1414 'core.quotePath=false',
1515 'diff',
16+ '--no-color',
1617 '--no-ext-diff',
1718 '--no-textconv',
1819 '--ignore-submodules=dirty',
@@ -148,6 +148,42 @@
148148 ).toBe(true)
149149 })
150150
151+ test("forced git colors do not hide a changed file's hunks", async () => {
152+ const deps = depsOf({
153+ 'HEAD --shortstat': Fixtures.ok(
154+ ' 1 file changed, 1 insertion(+), 1 deletion(-)',
155+ ),
156+ 'HEAD --numstat': Fixtures.ok('1\t1\ta.ts\0'),
157+ 'ls-files': Fixtures.ok(),
158+ })
159+
160+ const git = Fixtures.scriptedGitOf({
161+ '--no-color': Fixtures.ok('@@ -1 +1 @@\n-old\n+new\n'),
162+ diff: Fixtures.ok(
163+ '\x1b[36m@@ -1 +1 @@\x1b[m\n\x1b[31m-old\x1b[m\n' +
164+ '\x1b[32m+\x1b[m\x1b[32mnew\x1b[m\n',
165+ ),
166+ })
167+
168+ const outcome = await Git.fetchDiff(deps, 'uncommitted')
169+ const data = outcome.kind === 'data' ? outcome.data : null
170+ const [row] = data?.files ?? []
171+
172+ expect(data?.stats).toEqual({
173+ filesCount: 1,
174+ linesAdded: 1,
175+ linesRemoved: 1,
176+ })
177+
178+ expect(
179+ data && row ? await Git.fetchFileHunks(git.run, data, row) : null,
180+ ).toEqual({
181+ hunks: [{ oldStart: 1, newStart: 1, lines: ['-old', '+new'] }],
182+ isTruncated: false,
183+ isLarge: false,
184+ })
185+ })
186+
151187 test('uncommitted mode drops pre-session untracked files', async () => {
152188 const outcome = await Git.fetchDiff(
153189 depsOf(