Subject: Re: [PATCH] Extend sample pre-commit hook to check for non ascii filenames

From: Junio C Hamano <[email-masked]>
Date: Mon, 18 May 2009 07:42:31 -0700

Heiko Voigt <[email-masked]> 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 |
        cmd3

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