git/list[1] front-page[2] threads[3] people[4] search[5] about
 

Re: BUG: CR marker ^M doesn't show up in '-' lines of diffs when the ending of the removed line is CR+LF

From
FSFrank Schäfer <fschaefer.oss@googlemail.com>
Date
Nov 25, 2018, 14:03 UTC
Message-ID
<2858f03b-89a7-be52-501f-55b6d281bebc@googlemail.com>
In-Reply-To
<80ffe850-b966-a37b-09bd-44e04d769944@kdbg.org>
Am 24.11.18 um 23:07 schrieb Johannes Sixt:
> I don't think that there is anything to fix. If you have a file with
> CRLF in it, but you did not declare to Git that CRLF is the expected
> end-of-line indicator, then the CR *is* trailing whitespace (because
> the line ends at LF), and 'git diff' highlights it. 

Sure, it's correct to highlight it. But it doesn't highlight it in removed lines, just in added lines. I can see no good reason why removed and added lines should be treated differently.

Let me give you two real-life examples:
 
1) If CR+LF line termination is used in a file, changing the content of
a line (but not its termination) currently produces a diff like

-something +something_new^M

which causes the user to think he has changed the line ending (added a CR) although he didn't.

2) If someone/something unintentionally changes the line termination
from CR+LF to LF, it doesn't show up in the diff:

-something +something

I don't think this behavior makes sense. At least it's IMHO not what users expect to see. They want to see what's really going on, not to get confused.

Regards, Frank

Previous: Johannes SixtNext: Johannes Sixt
Message 6 of 23 in “BUG: CR marker ^M doesn't show up in '-' lines of diffs when the ending of the removed line is CR+LF”
  1. Frank SchäferNov 23, 2018
  2. Johannes SixtNov 23, 2018
  3. Frank SchäferNov 24, 2018
  4. Torsten BögershausenNov 24, 2018
  5. Johannes SixtNov 24, 2018
  6. Frank SchäferNov 25, 2018
  7. Johannes SixtNov 25, 2018
  8. Junio C HamanoNov 26, 2018
  9. brian m. carlsonNov 25, 2018
  10. Johannes SixtNov 26, 2018
  11. Junio C HamanoNov 26, 2018
  12. Johannes SixtNov 27, 2018
  13. Frank SchäferNov 27, 2018
  14. Junio C HamanoNov 29, 2018
  15. Frank SchäferDec 2, 2018
  16. Johannes SixtDec 2, 2018
  17. Frank SchäferDec 5, 2018
  18. Johannes SixtDec 5, 2018
  19. Junio C HamanoDec 3, 2018
  20. Frank SchäferDec 5, 2018
  21. Junio C HamanoDec 6, 2018
  22. Frank SchäferDec 6, 2018
  23. Frank SchäferNov 27, 2018

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.