Thread (16 messages) flat view 16 messages, 6 authors, 4d ago

Re: AI Textconv filter misconfiguration on Windows leads to silent corruption of diff output (ongoing investigation)

From: Skybuck Flying <hidden>
Date: 2026-08-11 02:13:28

I confronted Co-Pilot with it, according to Co-Pilot you will like this shorter report better, more to the point:

Hi,

I encountered an issue on Windows where a textconv filter intended to strip
carriage returns ends up corrupting diff output by removing literal 'r'
characters.

Configuration:

    [diff "lfclean"]
        textconv = sed -e s/\r//
    *.go diff=lfclean

Environment:
- Windows 10
- Git for Windows (2.x)
- sed from Git for Windows: usr/bin/sed.exe

Problem:
Running `git diff` on Go source files shows corrupted identifiers:
    compareCache → compaeCache
    return → eturn
    for → fo
    cacheReader → cacheReade
etc.

The repository content is correct:
- `git diff --no-textconv` shows correct diffs.
- `git show <commit>:<file>` shows correct content.

Reproduction outside Git:

    echo compareCache | C:\Tools\Git\usr\bin\sed.exe -e s/\r//

Output:

    compaeCache

So sed removes literal 'r' instead of carriage returns. It appears that on
Windows, the backslash in `\r` is not preserved through MSYS argument parsing,
effectively turning the expression into `s/r//`.

Impact:
- Diff output becomes misleading/corrupted.
- No warning is emitted.
- The issue is silent and difficult to diagnose.

Suggestion:
- Consider documenting that sed-based textconv filters using backslash escapes
  are unsafe on Windows.
- Possibly warn when textconv commands contain `\r` on Windows.
- A built-in CR-stripping textconv filter would avoid these pitfalls.

Thanks,
  Skybuck Flying

Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help