Problem: git diff thinks the file is binary:
$ git diff e7714 foo.txt
diff --git a/foo.txt b/foo.txt
index 14e06f9..9f00c64 100644
Binary files a/foo.txt and b/foo.txt differ
I know it has to do with encoding. Running dos2unix
fixes it.
$ dos2unix.exe foo.txt
dos2unix: converting UTF-16LE file foo.txt to UTF-8 Unix format...
Good, except if one forgets to run dos2unix
before commit and push, the diffs between versions are not informative. Conversion to non UTF-8 encoding is due to certain tools that people use to edit files (bad tools).
SVN has pre-commit hooks to deal with code formatting and other style issues. Is something like this available for git? For example, I would like to say that files named *.txt
must be UTF-8, else reject commit (or reject push, if commit-level reject is not possible).