Re: [git-users] hook file encoding for text files

2014-02-12 Thread Dale R. Worley
> From: Philipp Kraus 

> 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.

Well, you first have to come up with a concrete definition of what
distinguishes a file as "a text file".  Then you have to determine
what is an acceptable "file encoding".  Those two tasks are probably
harder to do in a way that actually works in your environment than you
think it is.

After you've done that, I expect that writing the hook is
straightforward, though I'm not familiar how hooks works.

Dale

-- 
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 git-users+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.


Re: [git-users] hook file encoding for text files

2014-02-12 Thread Konstantin Khomoutov
On Wed, 5 Feb 2014 23:41:51 -0800 (PST)
Philipp Kraus  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 git-users+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.


[git-users] hook file encoding for text files

2014-02-05 Thread Philipp Kraus
Hello,

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.

Hope for some help, thanks

Phil

-- 
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 git-users+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.