{"thread":{"id":"22921","subject":"core.autocrlf considered half-assed","startedAt":"2010-03-05T23:23:33Z","lastAt":"2010-03-09T17:11:15Z","messageCount":12,"participants":["Johannes Schindelin","Dmitry Potapov","Linus Torvalds","Tait","Junio C Hamano"],"isPatch":false,"patchVersion":null,"patchTotal":null},"messages":[{"id":"136225","messageId":"alpine.DEB.1.00.1003060018170.20986@pacific.mpi-cbg.de","threadId":"22921","inReplyTo":null,"subject":"core.autocrlf considered half-assed","fromName":"Johannes Schindelin","fromEmail":"johannes.schindelin@gmx.de","sentAt":"2010-03-05T23:23:33Z","receivedAt":"2010-03-05T23:23:33Z","isPatch":false,"sender":{"key":"johannes.schindelin@gmx.de","avatar":"https://avatars.githubusercontent.com/u/127790?v=4"},"body":"Hi,\n\nback then, I was not a fan of the core.autocrlf support. But I have to \nadmit that in the meantime, I turned into an outright un-fan of the \nfeature. Not because its intent is wrong, but because its implementation \nis lousy.\n\nJust try to \"git reset --hard\" or \"git stash\" when there are files with \nDOS line endings and when core.autocrlf is not false.\n\nAnd then despair.\n\nSo again, for the record this time: core.autocrlf=true is handled \n_lousily_.\n\nCiao,\nDscho\n"},{"id":"136240","messageId":"20100307092701.GC31105@dpotapov.dyndns.org","threadId":"22921","inReplyTo":"alpine.DEB.1.00.1003060018170.20986@pacific.mpi-cbg.de","subject":"Re: core.autocrlf considered half-assed","fromName":"Dmitry Potapov","fromEmail":"dpotapov@gmail.com","sentAt":"2010-03-07T09:27:01Z","receivedAt":"2010-03-07T09:27:01Z","isPatch":false,"sender":{"key":"dpotapov@gmail.com","avatar":"https://avatars.githubusercontent.com/u/6568595?v=4"},"body":"On Sat, Mar 06, 2010 at 12:23:33AM +0100, Johannes Schindelin wrote:\n> \n> back then, I was not a fan of the core.autocrlf support. But I have to \n> admit that in the meantime, I turned into an outright un-fan of the \n> feature. Not because its intent is wrong, but because its implementation \n> is lousy.\n\nWell, I agree there are some issues with it. In particularly, when\nsomeone changes core.autocrlf in his/her repository, and then git\nbehavior is outright confusing. IMHO, the nuts of the problem is that\ndoes not store in the index how files were checkout. Instead it uses\ncore.autocrlf, which specifies how the user _wants_ files to be check-\nout. So, when the autocrlf option changes, things get very confusing.\nHowever:\n\n> Just try to \"git reset --hard\" or \"git stash\" when there are files with \n> DOS line endings and when core.autocrlf is not false.\n\nI did, and I have not noticed any problem with that.\n\ngit init\ngit config core.autocrlf true\necho foo^ | tr ^ '\\r' > foo\ngit add foo\ngit commit -m 'add foo'\necho more^ | tr ^ '\\r' >> foo\necho \"Before reset:\"\ntr '\\r' ^ < foo\ngit reset --hard\necho \"After reset:\"\ngit diff\ntr '\\r' ^ < foo\n\n\nDmitry\n"},{"id":"136371","messageId":"alpine.LFD.2.00.1003071538350.30214@localhost.localdomain","threadId":"22921","inReplyTo":"20100307092701.GC31105@dpotapov.dyndns.org","subject":"Re: core.autocrlf considered half-assed","fromName":"Linus Torvalds","fromEmail":"torvalds@linux-foundation.org","sentAt":"2010-03-07T23:45:13Z","receivedAt":"2010-03-07T23:45:13Z","isPatch":false,"sender":{"key":"torvalds@linux-foundation.org","avatar":"https://avatars.githubusercontent.com/u/1024025?v=4"},"body":"\n\nOn Sun, 7 Mar 2010, Dmitry Potapov wrote:\n> \n> Well, I agree there are some issues with it. In particularly, when\n> someone changes core.autocrlf in his/her repository, and then git\n> behavior is outright confusing. IMHO, the nuts of the problem is that\n> does not store in the index how files were checkout. Instead it uses\n> core.autocrlf, which specifies how the user _wants_ files to be check-\n> out. So, when the autocrlf option changes, things get very confusing.\n\nI do agree. It would probably have been a good idea to mark the CRLF \nstatus in the index, but we didn't. And crlf isn't actually the _only_ \nthing that can cause confusion, the 'ident' and 'filter' can do the same \nthing.\n\nOne option might be to have \"git config\" know about crlf, so that if you \nchange crlf state with 'git config' rather than manually, we could at \nleast _warn_ about the effects and tell people that they may need to do a \nfull new checkout (or reset the stat info in the index, or whatever). But \nI like editing config files by hand, and I don't think I'm the only one.\n\n\t\t\tLinus\n"},{"id":"136384","messageId":"alpine.DEB.1.00.1003081225280.14277@intel-tinevez-2-302","threadId":"22921","inReplyTo":"20100307092701.GC31105@dpotapov.dyndns.org","subject":"Re: core.autocrlf considered half-assed","fromName":"Johannes Schindelin","fromEmail":"johannes.schindelin@gmx.de","sentAt":"2010-03-08T11:29:01Z","receivedAt":"2010-03-08T11:29:01Z","isPatch":false,"sender":{"key":"johannes.schindelin@gmx.de","avatar":"https://avatars.githubusercontent.com/u/127790?v=4"},"body":"Hi,\n\nOn Sun, 7 Mar 2010, Dmitry Potapov wrote:\n\n> On Sat, Mar 06, 2010 at 12:23:33AM +0100, Johannes Schindelin wrote:\n> \n> > Just try to \"git reset --hard\" or \"git stash\" when there are files \n> > with DOS line endings and when core.autocrlf is not false.\n> \n> I did, and I have not noticed any problem with that.\n> \n> git init\n> git config core.autocrlf true\n> echo foo^ | tr ^ '\\r' > foo\n> git add foo\n> git commit -m 'add foo'\n\nUnfortunately, this is not the common case. The common case is that \nsomebody committed _without_ autocrlf (implicitly =false), and you clone \nfrom there.\n\nEasiest example:\n\n$ git clone -n git://repo.or.cz/git.git html-docs\n$ cd html-docs/\n$ git config core.autocrlf true\n$ git checkout -t origin/html\n$ git status\n\n... and despair.\n\nHth,\nDscho\n"},{"id":"136402","messageId":"20100308185719.GQ2480@ece.pdx.edu","threadId":"22921","inReplyTo":"alpine.LFD.2.00.1003071538350.30214@localhost.localdomain","subject":"Re: core.autocrlf considered half-assed","fromName":"Tait","fromEmail":"git.git@t41t.com","sentAt":"2010-03-08T18:57:19Z","receivedAt":"2010-03-08T18:57:19Z","isPatch":false,"sender":{"key":"git.git@t41t.com","avatar":null},"body":"> I do agree. It would probably have been a good idea to mark the CRLF\n> status in the index, but we didn't...\n\nWe already have .gitattributes for tracking information about files. Maybe\nadd an attribute to describe the in-repository line endings? The default\nwould be LF, as now, and a new attribute could change the checked-in\nformat to be CRLF.\n\nTait\n"},{"id":"136403","messageId":"alpine.DEB.1.00.1003082011440.14277@intel-tinevez-2-302","threadId":"22921","inReplyTo":"20100308185719.GQ2480@ece.pdx.edu","subject":"Re: core.autocrlf considered half-assed","fromName":"Johannes Schindelin","fromEmail":"johannes.schindelin@gmx.de","sentAt":"2010-03-08T19:15:10Z","receivedAt":"2010-03-08T19:15:10Z","isPatch":false,"sender":{"key":"johannes.schindelin@gmx.de","avatar":"https://avatars.githubusercontent.com/u/127790?v=4"},"body":"Hi,\n\nOn Mon, 8 Mar 2010, Tait wrote:\n\n> > I do agree. It would probably have been a good idea to mark the CRLF \n> > status in the index, but we didn't...\n> \n> We already have .gitattributes for tracking information about files. \n> Maybe add an attribute to describe the in-repository line endings? The \n> default would be LF, as now, and a new attribute could change the \n> checked-in format to be CRLF.\n\nNo.\n\nThe problem is not the description of the line endings in the repository. \nThe information what line endings are used can be easily extracted from \nevery blob, by a simple inspection.\n\nThe problem is that the core.autocrlf code blindly assumes that Unix line \nendings are the only thing you would ever commit. And worse, the mistake \nis repeated when updating the index. Git converts the DOS line endings \ninto Unix line endings, then compares with what it has in the repository \nand says: \"Ooops, it is different!\" even if it just checked the files out.\n\nAnd I demonstrated with the \"html\" example that even long-time Gitsters \nsometimes commit DOS line endings as-are, unconverted.\n\nCiao,\nDscho\n"},{"id":"136410","messageId":"7v6356r1w9.fsf@alter.siamese.dyndns.org","threadId":"22921","inReplyTo":"alpine.DEB.1.00.1003082011440.14277@intel-tinevez-2-302","subject":"Re: core.autocrlf considered half-assed","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2010-03-08T20:31:34Z","receivedAt":"2010-03-08T20:31:34Z","isPatch":false,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"Johannes Schindelin <Johannes.Schindelin@gmx.de> writes:\n\n> And I demonstrated with the \"html\" example that even long-time Gitsters \n> sometimes commit DOS line endings as-are, unconverted.\n\nFWIW, not using CRLF conversion in the auto-generated 'html' repository\nwas a deliberate choice, as the contents there (the ones generated by\nAsciiDoc with '.html' suffix) were intended to be served directly from the\nweb servers.  I presume AsciiDoc writes them with CRLF because html\ndocuments are supposed to be, and it would be wrong to apply core.autocrlf\nin the auto-generated repository.  And it is not correct to force\ncore.autocrlf on the recipient side either.  I know you wanted to have a\nsample repository that people can easily access and understand what you\nsee as a problem, and the autogenerated 'html' is a good sample to point\nat for that purpose, but \"even long-time gitsters...\" is stretching the\ntruth.\n\nNevertheless, I agree with you that if a similar situation happened by\nmistake and your project does want to enforce core.autocrlf, it would be\nnicer if there is an easy-to-use one-time clean-up procedure.  It hasn't\nbeen my itch, and I suspect it wasn't Linus's itch either.\n"},{"id":"136427","messageId":"20100309072412.GF31105@dpotapov.dyndns.org","threadId":"22921","inReplyTo":"alpine.DEB.1.00.1003081225280.14277@intel-tinevez-2-302","subject":"Re: core.autocrlf considered half-assed","fromName":"Dmitry Potapov","fromEmail":"dpotapov@gmail.com","sentAt":"2010-03-09T07:24:12Z","receivedAt":"2010-03-09T07:24:12Z","isPatch":false,"sender":{"key":"dpotapov@gmail.com","avatar":"https://avatars.githubusercontent.com/u/6568595?v=4"},"body":"On Mon, Mar 08, 2010 at 12:29:01PM +0100, Johannes Schindelin wrote:\n> \n> Easiest example:\n> \n> $ git clone -n git://repo.or.cz/git.git html-docs\n> $ cd html-docs/\n> $ git config core.autocrlf true\n> $ git checkout -t origin/html\n> $ git status\n\nAs Junio explained in another mail, it was intentional to have all HTML\nfiles with CRLF, because they are supposed to have that ending on all\nplatforms. What is missing, however, is .gitattributes, which would tell\nto Git that we do not want to autocrlf conversion for HTML files. This\ncan be done by adding .gitattributes:\n\n$ cat >> .gitattributes <<EOF\n*.html -crlf\nEOF\n\nI've just noticed that user-manual.html differs from other HTML files in\nthat it uses LF ending. I think it is a mistake, and this file should be\nconverted to have CRLF, but if you want to have all HTML files except\nuser-manual.html to have CRLF then you can do that too:\n\n$ cat > .gitattributes <<EOF\n*.html -crlf\nuser-manual.html crlf\nEOF\n\nI hope Junio will add the right version of .gitattributes, so users with\nautocrlf=true will not suffer.\n\n\nDmitry\n"},{"id":"136421","messageId":"alpine.DEB.1.00.1003091026060.7596@pacific.mpi-cbg.de","threadId":"22921","inReplyTo":"7v6356r1w9.fsf@alter.siamese.dyndns.org","subject":"Re: core.autocrlf considered half-assed","fromName":"Johannes Schindelin","fromEmail":"johannes.schindelin@gmx.de","sentAt":"2010-03-09T09:28:13Z","receivedAt":"2010-03-09T09:28:13Z","isPatch":false,"sender":{"key":"johannes.schindelin@gmx.de","avatar":"https://avatars.githubusercontent.com/u/127790?v=4"},"body":"Hi,\n\nOn Mon, 8 Mar 2010, Junio C Hamano wrote:\n\n> Johannes Schindelin <Johannes.Schindelin@gmx.de> writes:\n> \n> > And I demonstrated with the \"html\" example that even long-time \n> > Gitsters sometimes commit DOS line endings as-are, unconverted.\n> \n> FWIW, not using CRLF conversion in the auto-generated 'html' repository\n> was a deliberate choice, as the contents there (the ones generated by\n> AsciiDoc with '.html' suffix) were intended to be served directly from the\n> web servers.  I presume AsciiDoc writes them with CRLF because html\n> documents are supposed to be, and it would be wrong to apply core.autocrlf\n> in the auto-generated repository.  And it is not correct to force\n> core.autocrlf on the recipient side either.\n\nAnd here you are wrong, because the branch contains _also_ .txt files that \nare _not_ CR/LF, but need to be CR/LF on Windows. Believe me, we did think \nabout what we were doing in msysGit. More than once.\n\n> Nevertheless, I agree with you that if a similar situation happened by \n> mistake and your project does want to enforce core.autocrlf, it would be \n> nicer if there is an easy-to-use one-time clean-up procedure.  It hasn't \n> been my itch, and I suspect it wasn't Linus's itch either.\n\nThe problem is that the whole thing was not your itch, but your \nimplementation. You never used it, so you never caught the obvious flaws \nin the design.\n\nSorry to be so direct, but it seems that my more subtle attempts to \nexplain the situation failed.\n\nCiao,\nDscho\n"},{"id":"136420","messageId":"alpine.DEB.1.00.1003091028440.7596@pacific.mpi-cbg.de","threadId":"22921","inReplyTo":"20100309072412.GF31105@dpotapov.dyndns.org","subject":"Re: core.autocrlf considered half-assed","fromName":"Johannes Schindelin","fromEmail":"johannes.schindelin@gmx.de","sentAt":"2010-03-09T09:29:20Z","receivedAt":"2010-03-09T09:29:20Z","isPatch":false,"sender":{"key":"johannes.schindelin@gmx.de","avatar":"https://avatars.githubusercontent.com/u/127790?v=4"},"body":"Hi,\n\nOn Tue, 9 Mar 2010, Dmitry Potapov wrote:\n\n> On Mon, Mar 08, 2010 at 12:29:01PM +0100, Johannes Schindelin wrote:\n> > \n> > Easiest example:\n> > \n> > $ git clone -n git://repo.or.cz/git.git html-docs\n> > $ cd html-docs/\n> > $ git config core.autocrlf true\n> > $ git checkout -t origin/html\n> > $ git status\n> \n> As Junio explained in another mail, it was intentional to have all HTML \n> files with CRLF, because they are supposed to have that ending on all \n> platforms. What is missing, however, is .gitattributes, which would tell \n> to Git that we do not want to autocrlf conversion for HTML files.\n\nThat is just papering over the real culprit: Git checks something out. \nThis should be clean. But then Git says it is not.\n\nCiao,\nDscho\n"},{"id":"136446","messageId":"20100309101101.GJ31105@dpotapov.dyndns.org","threadId":"22921","inReplyTo":"alpine.DEB.1.00.1003091028440.7596@pacific.mpi-cbg.de","subject":"Re: core.autocrlf considered half-assed","fromName":"Dmitry Potapov","fromEmail":"dpotapov@gmail.com","sentAt":"2010-03-09T10:11:01Z","receivedAt":"2010-03-09T10:11:01Z","isPatch":false,"sender":{"key":"dpotapov@gmail.com","avatar":"https://avatars.githubusercontent.com/u/6568595?v=4"},"body":"On Tue, Mar 09, 2010 at 10:29:20AM +0100, Johannes Schindelin wrote:\n> \n> That is just papering over the real culprit: Git checks something out. \n> This should be clean. But then Git says it is not.\n\nWe have two filters: from-git-to-worktree and from-worktree-to-git. If\nthose conversions are inconsistent for whatever reason, it is not going\nto be well even if we found a way to solve this not-being-clean-after-\ncheckout problem.\n\nOne possible approach is to mark all files that had CRLF conversion\nduring checkout and apply the opposite conversion only to them. But what\nabout newly added files? Wouldn't this lead that to the situation where\nnewly added files will have the incorrect ending?\n\nIMHO, this not clean after checkout repo demonstrates that you have the\nincorrectly crlf configuration in it. So, you probably should correct\n.gitattributes (or even to disable autocrlf in it if this repository is\nnot intended to be used with autocrlf=true). Either way, your current\nsettings are incorrect. It is better to fix it than try to hide it!\n\n\nDmitry\n"},{"id":"136457","messageId":"7vlje1zah8.fsf@alter.siamese.dyndns.org","threadId":"22921","inReplyTo":"alpine.DEB.1.00.1003091026060.7596@pacific.mpi-cbg.de","subject":"Re: core.autocrlf considered half-assed","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2010-03-09T17:11:15Z","receivedAt":"2010-03-09T17:11:15Z","isPatch":false,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"Johannes Schindelin <Johannes.Schindelin@gmx.de> writes:\n\n>> Nevertheless, I agree with you that if a similar situation happened by \n>> mistake and your project does want to enforce core.autocrlf, it would be \n>> nicer if there is an easy-to-use one-time clean-up procedure.  It hasn't \n>> been my itch, and I suspect it wasn't Linus's itch either.\n>\n> The problem is that the whole thing was not your itch, but your \n> implementation. You never used it, so you never caught the obvious flaws \n> in the design.\n>\n> Sorry to be so direct, but it seems that my more subtle attempts to \n> explain the situation failed.\n\nNo, being direct is good---it shows the thought behind what you say more\nclearly.\n\nThink what \"your implementation\" means in the open source setting.  It is\nwhat you were given for free, you could try to improve upon it if you so\ndesire, and you should be thankful for it.  It also means that you know\nthe people to ask for help as it is \"their\" implementation and they are\nprobably more familiar with it than others.  If you happen to be in the\nposition where you can see shortcomings in the implementation better than\nthey do, that's good; they and you can complement what each is good at,\nand make progress collectively.\n\nWhat it does _not_ mean is that you can _demand_ anything out of them,\nthough.  An attempt to shaming them into doing something amounts to the\nsame thing.  Having seen the way you have behaved on the msysgit list and\nits tracker for a while, I thought you understood all that.\n"}]}