{"thread":{"id":"51295","subject":"BUG: Git checkout on Linux sets always CRLF regardless of core.eol","startedAt":"2019-06-12T10:48:13Z","lastAt":"2019-06-12T20:02:27Z","messageCount":2,"participants":["Alexander","Torsten Bögershausen"],"isPatch":false,"patchVersion":null,"patchTotal":null},"messages":[{"id":"377059","messageId":"CABcYkASFxTe7Sq278EqCT1hBQq4Sh47-emNPJcnhA6YWZf+uQg@mail.gmail.com","threadId":"51295","inReplyTo":null,"subject":"BUG: Git checkout on Linux sets always CRLF regardless of core.eol","fromName":"Alexander","fromEmail":"alexander.samoylov@gmail.com","sentAt":"2019-06-12T10:48:00Z","receivedAt":"2019-06-12T10:48:13Z","isPatch":false,"sender":{"key":"alexander.samoylov@gmail.com","avatar":null},"body":"Hello,\n\nI am trying to checkout out various 3rd party Git projects on Linux\nand build them.\nSome of them have text files created under Windows with CRLF endings\nand it is not under my responsibility to change it.\n\nThus I have to force LF line ending for Git checkout (regardless of\nwhich line endings the files have in the repo). I use the following\nsettings for that:\n\n$ git config --system -l | grep core\ncore.eol=lf\n$ git config --global -l | grep core\ncore.eol=lf\n\nHowever it does not work. The issue is reproduced pretty fine on\nhttps://github.com/winlibs/libjpeg project. This project does not have\n.gitattributes file, therefore I expect that global settings must be\nenough to force LF, but I observe different behavior:\n\n$ git clone https://github.com/winlibs/libjpeg; file libjpeg/libjpeg.map\nCloning into 'libjpeg'...\n...\nlibjpeg/libjpeg.map: ASCII text, with CRLF line terminators\n(not only libjpeg.map, but a lot of *.c files also have CRLF if you check it)\n\nlibjpeg is an opensource project, so anyone can reproduce this issue\non a Linux host.\n\nThis makes me think that this it is either a bug or not documented behavior.\nI tried various combinations with core.eol, core.autocrlf and even\nglobal /etc/gitattributes file - nothing can force checkout with LF!\n\nCould you please confirm whether it is a bug and provide the clear way\nto bypass it.\n\nMy Git client version: 2.17.1. Please, see also\nstackoverflow.com/questions/56546220/git-checks-out-crlf-instead-of-lf-on-linux.\n\n--\nBest Regards,\nAleksandr Samoilov\nBuild & Integration Ingenieur\nCompart AG, 71034 Böblingen\n"},{"id":"377112","messageId":"20190612200222.odtht5uq2fzqpsmz@tb-raspi4","threadId":"51295","inReplyTo":"CABcYkASFxTe7Sq278EqCT1hBQq4Sh47-emNPJcnhA6YWZf+uQg@mail.gmail.com","subject":"Re: BUG: Git checkout on Linux sets always CRLF regardless of core.eol","fromName":"Torsten Bögershausen","fromEmail":"tboegi@web.de","sentAt":"2019-06-12T20:02:23Z","receivedAt":"2019-06-12T20:02:27Z","isPatch":false,"sender":{"key":"tboegi@web.de","avatar":"https://avatars.githubusercontent.com/u/7138363?v=4"},"body":"On Wed, Jun 12, 2019 at 12:48:00PM +0200, Alexander wrote:\n> Hello,\n>\n> I am trying to checkout out various 3rd party Git projects on Linux\n> and build them.\n> Some of them have text files created under Windows with CRLF endings\n> and it is not under my responsibility to change it.\n>\n> Thus I have to force LF line ending for Git checkout (regardless of\n> which line endings the files have in the repo). I use the following\n> settings for that:\n>\n> $ git config --system -l | grep core\n> core.eol=lf\n> $ git config --global -l | grep core\n> core.eol=lf\n>\n> However it does not work. The issue is reproduced pretty fine on\n> https://github.com/winlibs/libjpeg project. This project does not have\n> .gitattributes file, therefore I expect that global settings must be\n> enough to force LF, but I observe different behavior:\n>\n> $ git clone https://github.com/winlibs/libjpeg; file libjpeg/libjpeg.map\n> Cloning into 'libjpeg'...\n> ...\n> libjpeg/libjpeg.map: ASCII text, with CRLF line terminators\n> (not only libjpeg.map, but a lot of *.c files also have CRLF if you check it)\n>\n> libjpeg is an opensource project, so anyone can reproduce this issue\n> on a Linux host.\n>\n> This makes me think that this it is either a bug or not documented behavior.\n> I tried various combinations with core.eol, core.autocrlf and even\n> global /etc/gitattributes file - nothing can force checkout with LF!\n>\n> Could you please confirm whether it is a bug and provide the clear way\n> to bypass it.\n\nI can do neither-nor, so to say.\n\nWhenever there are CRLF in the repo,\nthere is no way for Git to change those into LF in the working tree.\n\nThe correct way is to normalize the repo:\nuser@linux:/tmp/libjpeg> git checkout -b normalize_EOL\nuser@linux:/tmp/libjpeg> echo \"* text=auto\" >.gitattributes\nuser@linux:/tmp/libjpeg> git add --renormalize .\nuser@linux:/tmp/libjpeg> git add .\nuser@linux:/tmp/libjpeg> git commit -m \"Normalize the repo; add .gitattributes\"\n\nAfter that, send a pull request to the original author.\n\nHTH\n>\n> My Git client version: 2.17.1. Please, see also\n> stackoverflow.com/questions/56546220/git-checks-out-crlf-instead-of-lf-on-linux.\n>\n> --\n> Best Regards,\n> Aleksandr Samoilov\n> Build & Integration Ingenieur\n> Compart AG, 71034 Böblingen\n"}]}