{"thread":{"id":"63782","subject":"Why doesn't git core.eol=lf work?","startedAt":"2025-07-12T09:45:51Z","lastAt":"2025-07-13T14:09:14Z","messageCount":7,"participants":["Jason Cho","Torsten Bögershausen","Johannes Sixt","Lidong Yan"],"isPatch":false,"patchVersion":null,"patchTotal":null},"messages":[{"id":"521863","messageId":"QcbAE4JJXpU-NcQ1loYdHthi-nYA2ZXcuuetCHE_0N0fRi0mdaf90VaLk0Y2ehrnVzoZraYO7jLhB7Pl68_k4l3HCqkFVGuMOzZ26cHYkfc=@proton.me","threadId":"63782","inReplyTo":"8jPyf4EU-z7W6OHX4j_kba2G-1c2RIDtgBcSkFjWSNhMuE6pxOOyxSGBnguoZvuDQSaJPypH0u1vLJf6FBX_ahUn3bBO_1DVscfOQm4Jovw=@proton.me","subject":"Why doesn't git core.eol=lf work?","fromName":"Jason Cho","fromEmail":"jason11choca@proton.me","sentAt":"2025-07-12T09:45:39Z","receivedAt":"2025-07-12T09:45:51Z","isPatch":false,"sender":{"key":"jason11choca@proton.me","avatar":null},"body":"```MINGW64 /tmp/summer-temp/dbeaver/docs ((e4219ccb38...))\n$ git log -1 --patch license_header.txt\ncommit b5121d4a6e8f3f21079920180b0fb14ada6d3349\nAuthor: serge-rider <serge@jkiss.org>\nDate:   Thu Jan 10 21:56:55 2019 +0300\n\n    License header update (2019)\n\ndiff --git a/docs/license_header.txt b/docs/license_header.txt\nindex 86de505a18..d75b48e98e 100644\n--- a/docs/license_header.txt\n+++ b/docs/license_header.txt\n@@ -1,5 +1,5 @@\n    DBeaver - Universal Database Manager\n-   Copyright (C) 2010-2018 Serge Rider (serge@jkiss.org)\n+   Copyright (C) 2010-2019 Serge Rider (serge@jkiss.org)^M\n\n    Licensed under the Apache License, Version 2.0 (the \"License\");\n    you may not use this file except in compliance with the License.\n\nMINGW64 /tmp/summer-temp/dbeaver/docs ((a3f59b66ed...))\n$ git check-attr --all -- license_header.txt\n\nMINGW64 /tmp/summer-temp/dbeaver/docs ((a3f59b66ed...))\n$ rm license_header.txt\n\nMINGW64 /tmp/summer-temp/dbeaver/docs ((a3f59b66ed...))\n$ git -c core.autocrlf=false -c core.eol=lf checkout -f HEAD -- license_header.txt\n\nMINGW64 /tmp/summer-temp/dbeaver/docs ((a3f59b66ed...))\n$ cat -A license_header.txt\n   DBeaver - Universal Database Manager^M$\n   Copyright (C) 2010-2019 Serge Rider (serge@jkiss.org)^M$\n^M$\n   Licensed under the Apache License, Version 2.0 (the \"License\");^M$\n   you may not use this file except in compliance with the License.^M$\n   You may obtain a copy of the License at^M$\n\nMINGW64 /tmp/summer-temp/dbeaver/docs ((a3f59b66ed...))\n$ git --version\ngit version 2.47.0.windows.2\n```\n\nI ask git to force checkout license_header.txt with LF line ending, but `cat` tells me the file is checked out with CRLF. Why?\n\n"},{"id":"521872","messageId":"20250712103030.GA30568@tb-raspi4","threadId":"63782","inReplyTo":"QcbAE4JJXpU-NcQ1loYdHthi-nYA2ZXcuuetCHE_0N0fRi0mdaf90VaLk0Y2ehrnVzoZraYO7jLhB7Pl68_k4l3HCqkFVGuMOzZ26cHYkfc=@proton.me","subject":"Re: Why doesn't git core.eol=lf work?","fromName":"Torsten Bögershausen","fromEmail":"tboegi@web.de","sentAt":"2025-07-12T10:30:30Z","receivedAt":"2025-07-12T10:30:39Z","isPatch":false,"sender":{"key":"tboegi@web.de","avatar":"https://avatars.githubusercontent.com/u/7138363?v=4"},"body":"On Sat, Jul 12, 2025 at 09:45:39AM +0000, Jason Cho wrote:\n> ```MINGW64 /tmp/summer-temp/dbeaver/docs ((e4219ccb38...))\n> $ git log -1 --patch license_header.txt\n> commit b5121d4a6e8f3f21079920180b0fb14ada6d3349\n> Author: serge-rider <serge@jkiss.org>\n> Date:   Thu Jan 10 21:56:55 2019 +0300\n> \n>     License header update (2019)\n> \n> diff --git a/docs/license_header.txt b/docs/license_header.txt\n> index 86de505a18..d75b48e98e 100644\n> --- a/docs/license_header.txt\n> +++ b/docs/license_header.txt\n> @@ -1,5 +1,5 @@\n>     DBeaver - Universal Database Manager\n> -   Copyright (C) 2010-2018 Serge Rider (serge@jkiss.org)\n> +   Copyright (C) 2010-2019 Serge Rider (serge@jkiss.org)^M\n> \n>     Licensed under the Apache License, Version 2.0 (the \"License\");\n>     you may not use this file except in compliance with the License.\n> \n> MINGW64 /tmp/summer-temp/dbeaver/docs ((a3f59b66ed...))\n> $ git check-attr --all -- license_header.txt\n> \n> MINGW64 /tmp/summer-temp/dbeaver/docs ((a3f59b66ed...))\n> $ rm license_header.txt\n> \n> MINGW64 /tmp/summer-temp/dbeaver/docs ((a3f59b66ed...))\n> $ git -c core.autocrlf=false -c core.eol=lf checkout -f HEAD -- license_header.txt\n> \n> MINGW64 /tmp/summer-temp/dbeaver/docs ((a3f59b66ed...))\n> $ cat -A license_header.txt\n>    DBeaver - Universal Database Manager^M$\n>    Copyright (C) 2010-2019 Serge Rider (serge@jkiss.org)^M$\n> ^M$\n>    Licensed under the Apache License, Version 2.0 (the \"License\");^M$\n>    you may not use this file except in compliance with the License.^M$\n>    You may obtain a copy of the License at^M$\n> \n> MINGW64 /tmp/summer-temp/dbeaver/docs ((a3f59b66ed...))\n> $ git --version\n> git version 2.47.0.windows.2\n> ```\n> \n> I ask git to force checkout license_header.txt with LF line ending, but `cat` tells me the file is checked out with CRLF. Why?\n> \nSide note: Did you  ?\nI would suspect that core.autocrlf=false switches off the CRLF handling.\nAnd this could be a command line:\ngit -c core.autocrlf=input -c core.eol=lf checkout -f HEAD -- license_header.txt\n\nBut now to the real stuff:\nIt may be that your file had been commited with LF or mixed CRLF into the repo.\nIn this case will Git not change CRLF into LF at checkout.\nWhat does\ngit ls-files --eol license_header.txt\ngive you ?\n\nBeside that, I would recommend to set up a .gitatrributes file\nand add it to the repo.\necho \"* text=auto\" >.gitattributes\ngit add --renormalize .\ngit commit -m \"Normalize line endings\"\n\n"},{"id":"521873","messageId":"hmmjz8ewCl8dl_K4NrydJHLRzLtjs8vGanKXkbJjDPgaaZvj9HzyzEkrY9WlciWgx0iNlcWPhwGpl1E2gxQkRpG_10KgmHDareAH7LQj33A=@proton.me","threadId":"63782","inReplyTo":"20250712103030.GA30568@tb-raspi4","subject":"Re: Why doesn't git core.eol=lf work?","fromName":"Jason Cho","fromEmail":"jason11choca@proton.me","sentAt":"2025-07-12T10:56:37Z","receivedAt":"2025-07-12T10:56:50Z","isPatch":false,"sender":{"key":"jason11choca@proton.me","avatar":null},"body":"> But now to the real stuff:\n> It may be that your file had been commited with LF or mixed CRLF into the repo.\n> In this case will Git not change CRLF into LF at checkout.\n> What does\n> git ls-files --eol license_header.txt\n> give you ?\n\n\n$ git ls-files --eol license_header.txt\ni/crlf  w/crlf  attr/                   license_header.txt\n\n\n \n> Beside that, I would recommend to set up a .gitatrributes file\n> and add it to the repo.\n> echo \"* text=auto\" >.gitattributes\n> \n> git add --renormalize .\n> git commit -m \"Normalize line endings\"\n\nI am building a tool to analyze codebases, such as which function is moved from one file to another. Different line endings fail string equality.\n\nAdmittedly I can make a local commit to normalize all files. But it's best if a simple config `core.eol` can work.\n"},{"id":"521875","messageId":"23f2bbea-1294-4773-89d8-b270e2c3bb52@kdbg.org","threadId":"63782","inReplyTo":"QcbAE4JJXpU-NcQ1loYdHthi-nYA2ZXcuuetCHE_0N0fRi0mdaf90VaLk0Y2ehrnVzoZraYO7jLhB7Pl68_k4l3HCqkFVGuMOzZ26cHYkfc=@proton.me","subject":"Re: Why doesn't git core.eol=lf work?","fromName":"Johannes Sixt","fromEmail":"j6t@kdbg.org","sentAt":"2025-07-12T13:35:04Z","receivedAt":"2025-07-12T13:35:21Z","isPatch":false,"sender":{"key":"j6t@kdbg.org","avatar":"https://avatars.githubusercontent.com/u/14810926?v=4"},"body":"Am 12.07.25 um 11:45 schrieb Jason Cho:\n> ```MINGW64 /tmp/summer-temp/dbeaver/docs ((e4219ccb38...))\n> $ git log -1 --patch license_header.txt\n> commit b5121d4a6e8f3f21079920180b0fb14ada6d3349\n> Author: serge-rider <serge@jkiss.org>\n> Date:   Thu Jan 10 21:56:55 2019 +0300\n> \n>     License header update (2019)\n> \n> diff --git a/docs/license_header.txt b/docs/license_header.txt\n> index 86de505a18..d75b48e98e 100644\n> --- a/docs/license_header.txt\n> +++ b/docs/license_header.txt\n> @@ -1,5 +1,5 @@\n>     DBeaver - Universal Database Manager\n> -   Copyright (C) 2010-2018 Serge Rider (serge@jkiss.org)\n> +   Copyright (C) 2010-2019 Serge Rider (serge@jkiss.org)^M\n> \n>     Licensed under the Apache License, Version 2.0 (the \"License\");\n>     you may not use this file except in compliance with the License.\n> \n\nSince you posted `git diff` output, may I ask if your concern is\nactually the ^M in the diff output, which you intend to fix with\nautomatic CRLF-to-LF conversion?\n\nIn that case, the simpler solution is to set core.whitespace such that\nit includes 'cr-at-eol' to convince `git diff` not to mark the CR in the\nCRLF pair as a trailing whitespace error.\n\n-- Hannes\n\n"},{"id":"521883","messageId":"sAxC2ASixUyCVtsk22zrxI2vAeM546T7O2tyWIS2vv_TGFo2OXWegg8J_r0zGzo5bZOA-BrwHa5yjAv2-Ewusjv9Fa9YYocrRkaIfpxhv_c=@proton.me","threadId":"63782","inReplyTo":"23f2bbea-1294-4773-89d8-b270e2c3bb52@kdbg.org","subject":"Re: Why doesn't git core.eol=lf work?","fromName":"Jason Cho","fromEmail":"jason11choca@proton.me","sentAt":"2025-07-12T19:15:00Z","receivedAt":"2025-07-12T19:15:15Z","isPatch":false,"sender":{"key":"jason11choca@proton.me","avatar":null},"body":"> \n> Since you posted `git diff` output, may I ask if your concern is\n> actually the ^M in the diff output, which you intend to fix with\n> automatic CRLF-to-LF conversion?\n> \n\nNo, my intent is to find moved or duplicated text among files. \n\nLet's say license_header.txt has \n\nDBeaver - Universal Database Manager^M\nCopyright (C) 2010-2018 Serge Rider (serge@jkiss.org)\n\nand another.txt has\n\nDBeaver - Universal Database Manager\nCopyright (C) 2010-2018 Serge Rider (serge@jkiss.org)\n\nMy tool doesn't think the two pieces of txt the same because of ^M.\n\nAlthough my tool can do normalization internally, if git checks out files to CRLF due to core.autocrlf=true, my tool is fighting against git. git shouldn't spend time converting to CRLF which is about to be converted back to LF by my tool.\n\nThat's why I set core.autocrlf=false, and ask git to normalize files to LF.\n\nSo the problem is that, conversion to LF is not happening.\n\n"},{"id":"521886","messageId":"C41F422E-8C9D-4BC7-BA0B-57B7D13D6557@gmail.com","threadId":"63782","inReplyTo":"sAxC2ASixUyCVtsk22zrxI2vAeM546T7O2tyWIS2vv_TGFo2OXWegg8J_r0zGzo5bZOA-BrwHa5yjAv2-Ewusjv9Fa9YYocrRkaIfpxhv_c=@proton.me","subject":"Re: Why doesn't git core.eol=lf work?","fromName":"Lidong Yan","fromEmail":"yldhome2d2@gmail.com","sentAt":"2025-07-13T07:43:55Z","receivedAt":"2025-07-13T07:44:10Z","isPatch":false,"sender":{"key":"yldhome2d2@gmail.com","avatar":"https://avatars.githubusercontent.com/u/77328395?v=4"},"body":"Jason Cho <jason11choca@proton.me> write:\n> \n>> \n>> Since you posted `git diff` output, may I ask if your concern is\n>> actually the ^M in the diff output, which you intend to fix with\n>> automatic CRLF-to-LF conversion?\n>> \n> \n> No, my intent is to find moved or duplicated text among files. \n> \n> Let's say license_header.txt has \n> \n> DBeaver - Universal Database Manager^M\n> Copyright (C) 2010-2018 Serge Rider (serge@jkiss.org)\n> \n> and another.txt has\n> \n> DBeaver - Universal Database Manager\n> Copyright (C) 2010-2018 Serge Rider (serge@jkiss.org)\n> \n> My tool doesn't think the two pieces of txt the same because of ^M.\n> \n> Although my tool can do normalization internally, if git checks out files to CRLF due to core.autocrlf=true, my tool is fighting against git. git shouldn't spend time converting to CRLF which is about to be converted back to LF by my tool.\n> \n> That's why I set core.autocrlf=false, and ask git to normalize files to LF.\n> \n> So the problem is that, conversion to LF is not happening.\n\nI believe that it's impossible to check out CRLF from the index as LF.\nYou have to use your tool to do that.\n\nThe definition of core.eol=lf is here:\n  https://git-scm.com/docs/gitattributes/2.9.5#:~:text=Set,-to%20string%20value%20%22lf\n\nThis means that when you use git add to stage files, Git will convert\nCRLF line endings to LF. However, when you check out files, Git will\nleave the line endings unchanged.\n\nThanks,\nLidong"},{"id":"521889","messageId":"wzZi9r7E7j1avCRjH89z3cdSJnwdoam1xRulfmRkybAYRIGxmZeZCYqRALW-b0B2lKnZ8xnuoAjwpWpMeDAx2oSW4qnlmS8iuUKit3And6Q=@proton.me","threadId":"63782","inReplyTo":"C41F422E-8C9D-4BC7-BA0B-57B7D13D6557@gmail.com","subject":"Re: Why doesn't git core.eol=lf work?","fromName":"Jason Cho","fromEmail":"jason11choca@proton.me","sentAt":"2025-07-13T14:08:56Z","receivedAt":"2025-07-13T14:09:14Z","isPatch":false,"sender":{"key":"jason11choca@proton.me","avatar":null},"body":"> \n> \n> I believe that it's impossible to check out CRLF from the index as LF.\n> You have to use your tool to do that.\n> \n> The definition of core.eol=lf is here:\n> https://git-scm.com/docs/gitattributes/2.9.5#:~:text=Set,-to string value \"lf\n> \n> This means that when you use git add to stage files, Git will convert\n> CRLF line endings to LF. However, when you check out files, Git will\n> leave the line endings unchanged.\n> \n\nI see. Thank you so much. This detail was so subtle and it totally flew under my radar.\n\n"}]}