There had been a lot of discussions about the core.autocrlf and core.safecrlf features in the current release and the next release. The question i have here relates to an environment where developers clone from a bare repository.
During the clone the autocrlf settings are enabled. But since the developers has full control on their clone, they can remove this autocrlf setting and proceed.
We can specify files other than binary in the .gitattributes file but is there any other way GIT automatically determine if a file is a text file or binary file?
Is there a way like an update hook (commit hook is not possible as developers can still remove it) that can be placed to make sure, the files (with CRLF) being pushed from a windows environment to a UNIX machine hosting the bare repo, is converted to UNIX EOL format (LF)?
Will having such update hooks that scans each file for CRLF affect performance of a push operation?
Thanks
1/ Git itself has an heuristic to determine if a file is binary or text (similar to istext)
2/ gergap weblog had recently (may 2010) the same idea.
See his update hook here (reproduced at the end of this answer), but the trick is:
Rather than trying to convert, the hook will simply reject the push if it detects an (supposedly) non-binary file with improper eol style.
Plus there is no actual conversion taking place: it the file is not correct, the push gets rejected.
That places the conversion issue right back where it should belong: on the developer side.