git@vger.kernel.org mailing list mirror (one of many)
 help / Atom feed
* git diff: meaning of ^M at line ends ?
@ 2018-05-14 16:08 Frank Schäfer
  2018-05-14 18:13 ` Torsten Bögershausen
  0 siblings, 1 reply; 4+ messages in thread
From: Frank Schäfer @ 2018-05-14 16:08 UTC (permalink / raw)
  To: git

What does ^M at the end of lines in the output of 'git diff' mean ?

Thanks,
Frank


^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: git diff: meaning of ^M at line ends ?
  2018-05-14 16:08 git diff: meaning of ^M at line ends ? Frank Schäfer
@ 2018-05-14 18:13 ` Torsten Bögershausen
  2018-05-15 18:04   ` Frank Schäfer
  0 siblings, 1 reply; 4+ messages in thread
From: Torsten Bögershausen @ 2018-05-14 18:13 UTC (permalink / raw)
  To: Frank Schäfer, git

On 14.05.18 18:08, Frank Schäfer wrote:
> What does ^M at the end of lines in the output of 'git diff' mean ?
> 
> Thanks,
> Frank
> 

^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.

If you want, you can commit those files with
CRLF in the working tree, and LF in the repo.

More information may be found here:

https://git-scm.com/docs/gitattributes

(Or ask more questions here, if needed)

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: git diff: meaning of ^M at line ends ?
  2018-05-14 18:13 ` Torsten Bögershausen
@ 2018-05-15 18:04   ` Frank Schäfer
  2018-05-18 15:03     ` Torsten Bögershausen
  0 siblings, 1 reply; 4+ messages in thread
From: Frank Schäfer @ 2018-05-15 18:04 UTC (permalink / raw)
  To: Torsten Bögershausen, git

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 ?
I didn't observe it before, although the project I'm currently looking
into has always been using CR+LF...

Why does the ^M only show up in '+' lines ?
When changing the line end from CR+LF to LF, the diff looks like this:

-blahblah
+blahblah

But I would expect it to be

-blahblah^M
+blahblah


Regards,
Frank

> If you want, you can commit those files with
> CRLF in the working tree, and LF in the repo.
>
> More information may be found here:
>
> https://git-scm.com/docs/gitattributes
>
> (Or ask more questions here, if needed)


^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: git diff: meaning of ^M at line ends ?
  2018-05-15 18:04   ` Frank Schäfer
@ 2018-05-18 15:03     ` Torsten Bögershausen
  0 siblings, 0 replies; 4+ messages in thread
From: Torsten Bögershausen @ 2018-05-18 15:03 UTC (permalink / raw)
  To: Frank Schäfer, git

On 15.05.18 20:04, Frank Schäfer wrote:
> 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:

> 
> -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


^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, back to index

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2018-05-14 16:08 git diff: meaning of ^M at line ends ? Frank Schäfer
2018-05-14 18:13 ` Torsten Bögershausen
2018-05-15 18:04   ` Frank Schäfer
2018-05-18 15:03     ` Torsten Bögershausen

git@vger.kernel.org mailing list mirror (one of many)

Archives are clonable:
	git clone --mirror https://public-inbox.org/git
	git clone --mirror http://ou63pmih66umazou.onion/git
	git clone --mirror http://czquwvybam4bgbro.onion/git
	git clone --mirror http://hjrcffqmbrq6wope.onion/git

Newsgroups are available over NNTP:
	nntp://news.public-inbox.org/inbox.comp.version-control.git
	nntp://ou63pmih66umazou.onion/inbox.comp.version-control.git
	nntp://czquwvybam4bgbro.onion/inbox.comp.version-control.git
	nntp://hjrcffqmbrq6wope.onion/inbox.comp.version-control.git
	nntp://news.gmane.org/gmane.comp.version-control.git

 note: .onion URLs require Tor: https://www.torproject.org/
       or Tor2web: https://www.tor2web.org/

AGPL code for this site: git clone https://public-inbox.org/ public-inbox