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

Re: git diff: meaning of ^M at line ends ?

From
Torsten Bögershausen <tboegi@web.de>
Date
May 18, 2018, 15:03 UTC
Message-ID
<a6b95cc0-0676-930e-9a42-325688d24675@web.de>
In-Reply-To
<ec5c536a-708a-1fd2-6ee2-98271b90b0fb@googlemail.com>
On 15.05.18 20:04, Frank Schäfer wrote:
Show 12 quoted lines
> Am 14.05.2018 um 20:13 schrieb Torsten Bögershausen:
>> ^M is the representation of a "Carriage Return" or CR.
>> Under Linux/Unix/Mac OS X a line is terminated with a single
>> "line feed", LF.
>>
>> Windows typically uses CRLF at the end of the line.
>> "git diff" uses the LF to detect the end of line,
>> leaving the CR alone.
>>
>> Nothing to worry about.
> Thanks, I already suspected something like that.
> Has this behavior been changed/added recently ?

That is a good question. There is, to my knowledge, no intentional change.

> I didn't observe it before, although the project I'm currently looking
> into has always been using CR+LF...

Do you mean that older versions did behave differently ? Do you have a version number for the "old" handling ?

> 
> Why does the ^M only show up in '+' lines ?
> When changing the line end from CR+LF to LF, the diff looks like this:
Show 8 quoted lines
> 
> -blahblah
> +blahblah
> 
> But I would expect it to be
> 
> -blahblah^M
> +blahblah

May be this helps (I haven't tested it) ? git config core.whitespace cr-at-eol

Previous: Frank Schäfer
Message 4 of 4 in “git diff: meaning of ^M at line ends ?”
  1. Frank SchäferMay 14, 2018
  2. Torsten BögershausenMay 14, 2018
  3. Frank SchäferMay 15, 2018
  4. Torsten BögershausenMay 18, 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.