From d4d21ceb1d83eba8ac30fafc5d9020fde1b6b0da Mon Sep 17 00:00:00 2001 From: Julian Prein Date: Fri, 30 May 2025 01:21:48 +0200 Subject: [PATCH] hooks:pre-commit: Update to git's current version The template has changed since I've added it. --- meta/git/hooks/pre-commit | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/meta/git/hooks/pre-commit b/meta/git/hooks/pre-commit index 4d85df8..d8792cc 100755 --- a/meta/git/hooks/pre-commit +++ b/meta/git/hooks/pre-commit @@ -13,22 +13,24 @@ if git rev-parse --verify HEAD >/dev/null 2>&1; then against=HEAD else # Initial commit: diff against an empty tree object - against=4b825dc642cb6eb9a060e54bf8d69288fbee4904 + against=$(git hash-object -t tree /dev/null) fi +# If you want to allow non-ASCII filenames set this variable to true. +allownonascii=$(git config --type=bool hooks.allownonascii) + # Redirect output to stderr. exec 1>&2 # Check that all filenames include only ASCII characters. -allownonascii=$(git config --bool hooks.allownonascii) if [ "$allownonascii" != "true" ]; then - # We exploit the fact that the printable range starts at the space character - # and ends with tilde. + # We exploit the fact that the printable range starts at the space + # character and ends with tilde. # Note that the use of brackets around a tr range is ok here, (it's # even required, for portability to Solaris 10's /usr/bin/tr), since # the square bracket bytes happen to fall in the designated range. num_nonascii=$( - git diff --cached --name-only --diff-filter=AR -z $against \ + git diff-index --cached --name-only --diff-filter=A -z $against \ | LC_ALL=C tr -d '[ -~]\0' \ | wc -c )