Re: [PATCH v2] Extend sample pre-commit hook to check for non ascii filenames
- From
Junio C Hamano <gitster@pobox.com>
- Date
- May 15, 2009, 18:11 UTC
- Message-ID
- <7vbpputewv.fsf@alter.siamese.dyndns.org>
- In-Reply-To
- <20090514175850.GA26267@macbook.lan>
Heiko Voigt <hvoigt@hvoigt.net> writes:
Show 12 quoted lines
> 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.
Show 9 quoted lines
> + exit 1 > + fi > +fi > + > if git-rev-parse --verify HEAD 2>/dev/null > then > against=HEAD > -- > 1.6.3