On Wed, 5 Feb 2014 23:41:51 -0800 (PST) Philipp Kraus <[email protected]> wrote:
> I try to write a pre-push hook in a bare repo. I would like to check > the file encoding on all text files, so how can I get all file types > that are handled as text file from git. > I have defined some types in the gitattributes. I'm afraid there's no definitive answer: the repo itself does not care about whether a file is "binary" or "test"--it just stores its contents. So... Either your bare repo should have its very own .gitattributes or you might have the pre-push hook extract this file from what's committed (or from some well-known commit, probably tagged appropriately), and then use it. In either case, you'll have to parse this file yourself as I'm afraid there's no git tool which would do that for you (in the spirit of `git config`). Still, it's not clear to me how you're supposed to "check the file encoding" on your blobs: if you intend to merely hunt for bytes with values >= 127, then multi-byte UTF-8 sequences might legitimately contain bytes with values >= 127, so the whole thing stinks IMO. You could possibly get away going from the other end--trying to `iconv` the file's contents from UTF-8 to whatever "ANSI encoding" your devs are supposed to have on their Windows boxes, and see if it fails--if it does, the file *might* be encoded in that ANSI encoding. -- You received this message because you are subscribed to the Google Groups "Git for human beings" group. To unsubscribe from this group and stop receiving emails from it, send an email to [email protected]. For more options, visit https://groups.google.com/groups/opt_out.
