Diff panel shows "No diff content" for every tracked file when diff.mnemonicPrefix is set

Status Open
Reported on v2.1.260
Maintainer reply None cached
Activity 1 comment · opened Sep 9, 2026

Summary

With diff.mnemonicPrefix = true in git config, the fullscreen diff panel (/diff, added in 2.1.260) renders the file list and per-file +/- counts correctly, but every tracked file's body reads No diff content.

The hunk parser hard-codes the default a/ / b/ path prefixes:

let k = (p === -1 ? d : d.slice(0, p)).match(/^a\/(.+?) b\/(.+)$/);
if (!k) continue;   // file silently gets zero hunks

Under diff.mnemonicPrefix, git emits diff --git c/path w/path (commit / working tree), the regex fails, and each file is skipped with no hunks and no diagnostic.

The file list stays correct because it comes from --numstat, whose output carries no path prefixes. That split is exactly what makes the symptom confusing: correct file names and line counts, empty diffs.

The git argv used for the probe is

--no-optional-locks -c diff.relative=false diff --ignore-submodules=dirty --submodule=short --no-ext-diff --no-textconv HEAD

It pins diff.relative, but not diff.mnemonicPrefix, diff.noprefix, or diff.srcPrefix / diff.dstPrefix — so user git config leaks into the parse.

Reproduction

git config --global diff.mnemonicPrefix true
cd any-repo
# modify a tracked file
claude          # fullscreen renderer
/diff

The panel header and file list are right; every tracked file's body shows No diff content. Unset the config and the diffs render.

Verification

I extracted the parser from the 2.1.266 binary and ran it verbatim against my repo's real diff output:

| config | first line of git diff output | files parsed |
|---|---|---|
| diff.mnemonicPrefix=true | diff --git c/Client/... | 0 |
| -c diff.mnemonicPrefix=false | diff --git a/Client/... | 4 (8 hunks) |

I also replicated the raw-blob path (ls-tree -r -l -z --full-tree HEAD + cat-file blob + in-process diff) on the same files, and it produces correct hunks — so only the git-diff-text path is affected.

Suggested fix

Pin the prefixes in the probe argv so user config cannot change them:

-c diff.mnemonicPrefix=false -c diff.noprefix=false --src-prefix=a/ --dst-prefix=b/

Making the parser prefix-agnostic (match ^(\S+?)/(.+?) (\S+?)/(.+)$, or read the paths from the --- / +++ lines) would be more robust still. Either way, a header that fails to parse deserves a log line rather than a silent continue.

Related

diff.noprefix = true and custom diff.srcPrefix / diff.dstPrefix break it the same way, so this affects more configurations than just mnemonicPrefix.

Environment

  • Claude Code 2.1.266 (native install, fullscreen renderer)
  • Windows 11 Pro 26200
  • git 2.38.1.windows.1
  • diff.mnemonicprefix = true in ~/.gitconfig

View original on GitHub ↗

This issue has 1 comment on GitHub. Read the full discussion on GitHub ↗