{"thread":{"id":"25167","subject":"what file extensions must be explicitly configured with respect to eol-type in gitattributes?","startedAt":"2010-09-20T16:19:38Z","lastAt":"2010-09-20T16:51:49Z","messageCount":2,"participants":["Robert Buck","Erik Faye-Lund"],"isPatch":false,"patchVersion":null,"patchTotal":null},"messages":[{"id":"151129","messageId":"AANLkTikK2oL3sUYHdqoQ7C47nd6Pi53N17GSfh8nx6Q-@mail.gmail.com","threadId":"25167","inReplyTo":null,"subject":"what file extensions must be explicitly configured with respect to eol-type in gitattributes?","fromName":"Robert Buck","fromEmail":"buck.robert.j@gmail.com","sentAt":"2010-09-20T16:19:38Z","receivedAt":"2010-09-20T16:19:38Z","isPatch":false,"sender":{"key":"buck.robert.j@gmail.com","avatar":"https://gravatar.com/avatar/1686742e8ac2595378aac67f26fd638ddaf494194f9af0cb6082c4a7eca1a366?d=mp&s=160"},"body":"Hello,\n\nOne project we have in house has approximately 160 different file\nextensions used for the files checked in. In our repository there are\nfiles that MUST be CRLF (.bat, .cmd, .vcproj, etc), files that MUST be\nLF (.xml, .xsl, .sh, etc), and files that MUST be binary. All others\nare just text and so long as they appear in native form I'd be happy.\n\nIt would seem a default rule to handle text files would make sense:\n\n* text=auto\n\nBut I have not found material explaining how git identifies binary\nfiles, so one concern would be that it could mangle binary file types\nin some cases.\n\nDo I have to explicitly mention all 160 file types in the gitattributes file?\n\nHow does git internally determine whether a file is text vs binary?\nDoes it use the 'file' command in Unix?\n\nAnd where I am going with this specifically is a question: what rules\nMUST be specifically stated in gitattributes and what rules are there\nimplicitly?\n\nThank you,\n\nBob\n"},{"id":"151131","messageId":"AANLkTikJO631YDE_UpNrC-4kjc_LF5_Gb8Xv7pCJfOf=@mail.gmail.com","threadId":"25167","inReplyTo":"AANLkTikK2oL3sUYHdqoQ7C47nd6Pi53N17GSfh8nx6Q-@mail.gmail.com","subject":"Re: what file extensions must be explicitly configured with respect to eol-type in gitattributes?","fromName":"Erik Faye-Lund","fromEmail":"kusmabite@gmail.com","sentAt":"2010-09-20T16:51:49Z","receivedAt":"2010-09-20T16:51:49Z","isPatch":false,"sender":{"key":"kusmabite@gmail.com","avatar":"https://avatars.githubusercontent.com/u/47073?v=4"},"body":"On Mon, Sep 20, 2010 at 6:19 PM, Robert Buck <buck.robert.j@gmail.com> wrote:\n> Hello,\n>\n> One project we have in house has approximately 160 different file\n> extensions used for the files checked in. In our repository there are\n> files that MUST be CRLF (.bat, .cmd, .vcproj, etc), files that MUST be\n> LF (.xml, .xsl, .sh, etc), and files that MUST be binary. All others\n> are just text and so long as they appear in native form I'd be happy.\n>\n> It would seem a default rule to handle text files would make sense:\n>\n> * text=auto\n>\n> But I have not found material explaining how git identifies binary\n> files, so one concern would be that it could mangle binary file types\n> in some cases.\n>\n> Do I have to explicitly mention all 160 file types in the gitattributes file?\n\nIf you want to be 100% sure, yes.\n\n> How does git internally determine whether a file is text vs binary?\n> Does it use the 'file' command in Unix?\n\nNo. Git applies the following heuristics to the file content:\n- Does the file contain any NUL-characters? If so, it's binary.\n- Is the ratio of printable characters vs non-printable characters\n(when interpreted as ascii) below 128? If so, it's binary.\n- Otherwise, it's text.\n\nYou can find the exact function here (beware of wrapping):\nhttp://git.kernel.org/?p=git/git.git;a=blob;f=convert.c;h=01de9a84c21b31a0120065a32a386f27321cdf7b;hb=HEAD#l77\n\nIn general, this works pretty well. In addition, there's the\ncore.safecrlf configuration variable, which can be used to protect you\nagainst normalizing the file in such a way that the exact original\nfile can't be recovered.\n\n> And where I am going with this specifically is a question: what rules\n> MUST be specifically stated in gitattributes and what rules are there\n> implicitly?\n\nGiven the above information, you should be able to figure this one out\nfor yourself. The answer depends on how pedantic you are ;)\n"}]}