git@vger.kernel.org list mirror (unofficial, one of many)
 help / color / Atom feed
* BUG: Git checkout on Linux sets always CRLF regardless of core.eol
@ 2019-06-12 10:48 Alexander
  2019-06-12 20:02 ` Torsten Bögershausen
  0 siblings, 1 reply; 2+ messages in thread
From: Alexander @ 2019-06-12 10:48 UTC (permalink / raw)
  To: git

Hello,

I am trying to checkout out various 3rd party Git projects on Linux
and build them.
Some of them have text files created under Windows with CRLF endings
and it is not under my responsibility to change it.

Thus I have to force LF line ending for Git checkout (regardless of
which line endings the files have in the repo). I use the following
settings for that:

$ git config --system -l | grep core
core.eol=lf
$ git config --global -l | grep core
core.eol=lf

However it does not work. The issue is reproduced pretty fine on
https://github.com/winlibs/libjpeg project. This project does not have
.gitattributes file, therefore I expect that global settings must be
enough to force LF, but I observe different behavior:

$ git clone https://github.com/winlibs/libjpeg; file libjpeg/libjpeg.map
Cloning into 'libjpeg'...
...
libjpeg/libjpeg.map: ASCII text, with CRLF line terminators
(not only libjpeg.map, but a lot of *.c files also have CRLF if you check it)

libjpeg is an opensource project, so anyone can reproduce this issue
on a Linux host.

This makes me think that this it is either a bug or not documented behavior.
I tried various combinations with core.eol, core.autocrlf and even
global /etc/gitattributes file - nothing can force checkout with LF!

Could you please confirm whether it is a bug and provide the clear way
to bypass it.

My Git client version: 2.17.1. Please, see also
stackoverflow.com/questions/56546220/git-checks-out-crlf-instead-of-lf-on-linux.

--
Best Regards,
Aleksandr Samoilov
Build & Integration Ingenieur
Compart AG, 71034 Böblingen

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

* Re: BUG: Git checkout on Linux sets always CRLF regardless of core.eol
  2019-06-12 10:48 BUG: Git checkout on Linux sets always CRLF regardless of core.eol Alexander
@ 2019-06-12 20:02 ` Torsten Bögershausen
  0 siblings, 0 replies; 2+ messages in thread
From: Torsten Bögershausen @ 2019-06-12 20:02 UTC (permalink / raw)
  To: Alexander; +Cc: git

On Wed, Jun 12, 2019 at 12:48:00PM +0200, Alexander wrote:
> Hello,
>
> I am trying to checkout out various 3rd party Git projects on Linux
> and build them.
> Some of them have text files created under Windows with CRLF endings
> and it is not under my responsibility to change it.
>
> Thus I have to force LF line ending for Git checkout (regardless of
> which line endings the files have in the repo). I use the following
> settings for that:
>
> $ git config --system -l | grep core
> core.eol=lf
> $ git config --global -l | grep core
> core.eol=lf
>
> However it does not work. The issue is reproduced pretty fine on
> https://github.com/winlibs/libjpeg project. This project does not have
> .gitattributes file, therefore I expect that global settings must be
> enough to force LF, but I observe different behavior:
>
> $ git clone https://github.com/winlibs/libjpeg; file libjpeg/libjpeg.map
> Cloning into 'libjpeg'...
> ...
> libjpeg/libjpeg.map: ASCII text, with CRLF line terminators
> (not only libjpeg.map, but a lot of *.c files also have CRLF if you check it)
>
> libjpeg is an opensource project, so anyone can reproduce this issue
> on a Linux host.
>
> This makes me think that this it is either a bug or not documented behavior.
> I tried various combinations with core.eol, core.autocrlf and even
> global /etc/gitattributes file - nothing can force checkout with LF!
>
> Could you please confirm whether it is a bug and provide the clear way
> to bypass it.

I can do neither-nor, so to say.

Whenever there are CRLF in the repo,
there is no way for Git to change those into LF in the working tree.

The correct way is to normalize the repo:
user@linux:/tmp/libjpeg> git checkout -b normalize_EOL
user@linux:/tmp/libjpeg> echo "* text=auto" >.gitattributes
user@linux:/tmp/libjpeg> git add --renormalize .
user@linux:/tmp/libjpeg> git add .
user@linux:/tmp/libjpeg> git commit -m "Normalize the repo; add .gitattributes"

After that, send a pull request to the original author.

HTH
>
> My Git client version: 2.17.1. Please, see also
> stackoverflow.com/questions/56546220/git-checks-out-crlf-instead-of-lf-on-linux.
>
> --
> Best Regards,
> Aleksandr Samoilov
> Build & Integration Ingenieur
> Compart AG, 71034 Böblingen

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

end of thread, back to index

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-06-12 10:48 BUG: Git checkout on Linux sets always CRLF regardless of core.eol Alexander
2019-06-12 20:02 ` Torsten Bögershausen

git@vger.kernel.org list mirror (unofficial, 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/

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