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

Skybuck Flying <[email protected]>
Newsgroups org.kernel.vger.git
Message-ID <AM0PR02MB445083767BAE669D4656CA6CB3DD2@AM0PR02MB4450.eurprd02.prod.outlook.com>
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
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.