Am 23.11.18 um 19:19 schrieb Frank Schäfer:
The CR marker ^M doesn't show up in '-' lines of diffs when the ending
of the removed line is CR+LF.
It shows up as expected in '-' lines when the ending of the removed line
is CR only.
It also always shows up as expected in '+' lines.
Is your repository configured to (1) highlight whitespace errors in diff
output and (2) to leave CRLF alone in text files?
If so, then it is just a side-effect of this combination, an illusion,
so to say: The CR in the CRLF combo is trailing whitespace. The 'git
diff' marks it by inserting an escape sequence to switch the color
before ^M and another escape sequence to reset to color after ^M. This
breaks the CRLF combination apart, so that the pager does not process it
as a combined CRLF sequence; it displays the lone CR as ^M.
It is easy to achieve the opposite effect, i.e., that ^M is not
displayed. For example with these lines in .git/info/attributes or
.gitattributes:
*.cpp
whitespace=trailing-space,cr-at-eol,indent-with-non-tab,space-before-tab
*.h whitespace=trailing-space,cr-at-eol,indent-with-non-tab,space-before-tab
Note the cr-at-eol. (There may be shorter versions to achieve a similar
effect.)
-- Hannes