Re: [PATCH] Extend sample pre-commit hook to check for non ascii filenames
- From
Junio C Hamano <gitster@pobox.com>
- Date
- May 18, 2009, 14:42 UTC
- Message-ID
- <7v3ab2ealk.fsf@alter.siamese.dyndns.org>
- In-Reply-To
- <20090518095044.GB910@heiko-voigts-macbook.local>
Heiko Voigt <hvoigt@hvoigt.net> writes:
> +if [ "$allownonascii" != "true" ] > +then > + # until git can handle non-ascii filenames gracefully > + # prevent them to be added into the repository
I think you can inline your is_ascii shell function in the pipeline below. You made it a separate function and I agree that it has a very good documentation value, but the mention of "non-ascii filenames" in this comment here is enough clue to let anybody know what is going on.
Side note: I am not sure "Until ... can ... gracefully" is a good
description of the general problem. It probably is more neutral
to say "Cross platform projects tend to avoid non-ascii filenames;
prevent them from being added to the repository."> + if ! git diff --cached --name-only --diff-filter=A -z \ > + | tr "\0" "\n" | is_ascii; then
A standard trick while writing a long pipeline in shell is to change line after a pipe, like:
cmd1 |
cmd2 |
cmd3which allows you to lose the BS-before-LF sequence.
I think comments from J6t and others are valuable but clear enough that I wouldn't have to repeat them.