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

From: Junio C Hamano <[email-masked]>
Date: Fri, 15 May 2009 11:11:12 -0700

Heiko Voigt <[email-masked]> writes:

> diff --git a/templates/hooks--pre-commit.sample b/templates/hooks--pre-commit.sample
> index 0e49279..3083735 100755
> --- a/templates/hooks--pre-commit.sample
> +++ b/templates/hooks--pre-commit.sample
> @@ -7,6 +7,26 @@
>  #
>  # To enable this hook, rename this file to "pre-commit".
>  
> +# If you want to allow non-ascii filenames set this variable to true.
> +allownonascii=$(git config hooks.allownonascii)
> +
> +function is_ascii () {

We do not say "#!/bin/bash" at the beginning (hopefully), so let's not say
"function " here.

> +    test -z "$(cat | sed -e "s/[\ -~]*//g")"

Do you need "cat | "?

Does this script run under LC_ALL=C?  Can an i18n'ized sed interfere with
what you are trying to do?

> +    return $?

Do you need this, or does the function return the result of the last
statment anyway?

> +		echo "Non-ascii filenames are not allowed !"
> +		echo "Please rename the file ..."

Can we make this sound more like a _sample_ project policy?  It's not like
we enforce that policy to other people's projects.

> +		exit 1
> +	fi
> +fi
> +
>  if git-rev-parse --verify HEAD 2>/dev/null
>  then
>  	against=HEAD
> -- 
> 1.6.3