{"thread":{"id":"39018","subject":"EOL conversion on checkout for text files only","startedAt":"2015-04-06T18:05:55Z","lastAt":"2015-04-07T08:47:56Z","messageCount":2,"participants":["Borek Bernard","Torsten Bögershausen"],"isPatch":false,"patchVersion":null,"patchTotal":null},"messages":[{"id":"259092","messageId":"CAHNoia06Q-jsskQn6TBkT8zPY7m14qmEL70HBm18CA-SaMrWtg@mail.gmail.com","threadId":"39018","inReplyTo":null,"subject":"EOL conversion on checkout for text files only","fromName":"Borek Bernard","fromEmail":"borekb@gmail.com","sentAt":"2015-04-06T18:05:55Z","receivedAt":"2015-04-06T18:05:55Z","isPatch":false,"sender":{"key":"borekb@gmail.com","avatar":null},"body":"Hi,\n\nI'd like to propose a new behavior around EOL normalization / forcing\nusing gitattributes.\n\nMy use case is this: I want to ensure that LF line endings are used in\nthe repo *and* in all working directories, on all platforms (in our\ncase, the text files MUST be LF even on Windows).\n\nThe first part is easy to achieve using this in a .gitattributes file:\n\n    * text=auto\n\nThis will correctly normalize *text files* in the repo. However, the\nsecond part (LF forcing on checkout) cannot be achieved easily today\nbecause adding `eol=lf` will unfortunately process binary files too.\nThe only solution today is to mark certain types for conversion (e.g.,\n`*.txt eol=lf`) or, inversely, mark certain types as binary (e.g.,\n`*.png binary`).\n\nBoth of these suffer from the same issue: the specific file types must\nbe listed explicitly in the .gitattributes file, which means that\neither the types must be known ahead of time or all developers must\nremember to update the .gitattributes file every time a new file type\nappears in the project. Which they won't.\n\nThe simplest solution in my eyes would be just to change the behavior of\n\n    * text=auto eol=lf\n\nto do both the checkin and checkout EOL conversions on *text files\nonly*, using the same text/binary detection algorithm that is already\nin place for the checkin direction. This feels the most intuitive to\nme and I think it would not be a breaking change.\n\nRelated IRC discussion:\nhttp://colabti.org/irclogger/irclogger_log/git?date=2015-04-04#l1143\n\nThoughts?\n\nThanks,\nBorek\n"},{"id":"259120","messageId":"552399BC.5030401@web.de","threadId":"39018","inReplyTo":"CAHNoia06Q-jsskQn6TBkT8zPY7m14qmEL70HBm18CA-SaMrWtg@mail.gmail.com","subject":"Re: EOL conversion on checkout for text files only","fromName":"Torsten Bögershausen","fromEmail":"tboegi@web.de","sentAt":"2015-04-07T08:47:56Z","receivedAt":"2015-04-07T08:47:56Z","isPatch":false,"sender":{"key":"tboegi@web.de","avatar":"https://avatars.githubusercontent.com/u/7138363?v=4"},"body":"On 2015-04-06 20.05, Borek Bernard wrote:\n> Hi,\n> \n> I'd like to propose a new behavior around EOL normalization / forcing\n> using gitattributes.\n> \n> My use case is this: I want to ensure that LF line endings are used in\n> the repo *and* in all working directories, on all platforms (in our\n> case, the text files MUST be LF even on Windows).\n> \n> The first part is easy to achieve using this in a .gitattributes file:\n> \n>     * text=auto\n> \n> This will correctly normalize *text files* in the repo. However, the\n> second part (LF forcing on checkout) cannot be achieved easily today\n> because adding `eol=lf` will unfortunately process binary files too.\n> The only solution today is to mark certain types for conversion (e.g.,\n> `*.txt eol=lf`) or, inversely, mark certain types as binary (e.g.,\n> `*.png binary`).\n> \n> Both of these suffer from the same issue: the specific file types must\n> be listed explicitly in the .gitattributes file, which means that\n> either the types must be known ahead of time or all developers must\n> remember to update the .gitattributes file every time a new file type\n> appears in the project. Which they won't.\n> \n> The simplest solution in my eyes would be just to change the behavior of\n> \n>     * text=auto eol=lf\n> \n> to do both the checkin and checkout EOL conversions on *text files\n> only*, using the same text/binary detection algorithm that is already\n> in place for the checkin direction. This feels the most intuitive to\n> me and I think it would not be a breaking change.\n> \n> Related IRC discussion:\n> http://colabti.org/irclogger/irclogger_log/git?date=2015-04-04#l1143\n> \n> Thoughts?\n> \n> Thanks,\n> Borek\n\nI think the suggestion makes sense.\n\nI could find 2 things that needs to be improved:\n\n- (1) Specifying \"eol=lf\" currently overwrites text=auto, this is in convert.c\n\n- (2) The .gitattributes file should overrule core.autocrlf.\n      This is what the documentation says, but the code doesn't work like that.\n      See convert.c, output_eol()\n\n- (3) we don't have test cases.\n\nI can probably contribute with 3) and may be 1), but the major work is to improve (or re-factor)\nthe code in convert.c\n\n\n\n \n"}]}