FYI, >From 635bcd0d19a1f8d16cb74eac3cdbf1c2694063ed Mon Sep 17 00:00:00 2001 From: Jim Meyering <meyer...@redhat.com> Date: Sat, 12 Nov 2011 14:00:18 +0100 Subject: [PATCH 1/2] maint: sync pre-commit script with git's
* scripts/git-hooks/pre-commit (allownonascii): Remove double quotes around $(...) construct, to make this file identical to git's sample hook script. --- scripts/git-hooks/pre-commit | 4 ++-- 1 files changed, 2 insertions(+), 2 deletions(-) diff --git a/scripts/git-hooks/pre-commit b/scripts/git-hooks/pre-commit index 1addec5..18c4829 100755 --- a/scripts/git-hooks/pre-commit +++ b/scripts/git-hooks/pre-commit @@ -28,8 +28,8 @@ if [ "$allownonascii" != "true" ] && # 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. - test "$(git diff --cached --name-only --diff-filter=A -z $against | - LC_ALL=C tr -d '[ -~]\0' | wc -c)" != 0 + test $(git diff --cached --name-only --diff-filter=A -z $against | + LC_ALL=C tr -d '[ -~]\0' | wc -c) != 0 then echo "Error: Attempt to add a non-ascii file name." echo -- 1.7.8.rc0.61.g8a042 >From 7bd653dada12e0f12f081ea9cccdf85a728052cd Mon Sep 17 00:00:00 2001 From: Jim Meyering <meyer...@redhat.com> Date: Sat, 12 Nov 2011 22:23:09 +0100 Subject: [PATCH 2/2] maint: add rule to ensure that our commit hook copies are up to date * Makefile.am (check-git-hook-script-sync): New rule -- not used anywhere, because it depends on having very recent git. * scripts/git-hooks/pre-applypatch: New file. --- Makefile.am | 14 ++++++++++++++ scripts/git-hooks/pre-applypatch | 14 ++++++++++++++ 2 files changed, 28 insertions(+), 0 deletions(-) create mode 100755 scripts/git-hooks/pre-applypatch diff --git a/Makefile.am b/Makefile.am index 1ec2b36..716cbdd 100644 --- a/Makefile.am +++ b/Makefile.am @@ -155,3 +155,17 @@ THANKS: THANKS.in Makefile.am .mailmap thanks-gen .version echo; \ printf ';; %s\n' 'Local Variables:' 'coding: utf-8' End:; \ } > $@-t && mv $@-t $@ + +# Some of our git hook scripts are supposed to be identical to git's samples. +# See if they are still in sync. +.PHONY: check-git-hook-script-sync +check-git-hook-script-sync: + @fail=0; \ + t=$$(mktemp -d) \ + && cd $$t && git init -q && cd .git/hooks \ + && for i in pre-commit pre-applypatch applypatch-msg; do \ + diff $(abs_top_srcdir)/scripts/git-hooks/$$i $$i.sample \ + || fail=1; \ + done; \ + rm -rf $$t; \ + test $$fail = 0 diff --git a/scripts/git-hooks/pre-applypatch b/scripts/git-hooks/pre-applypatch new file mode 100755 index 0000000..b1f187c --- /dev/null +++ b/scripts/git-hooks/pre-applypatch @@ -0,0 +1,14 @@ +#!/bin/sh +# +# An example hook script to verify what is about to be committed +# by applypatch from an e-mail message. +# +# The hook should exit with non-zero status after issuing an +# appropriate message if it wants to stop the commit. +# +# To enable this hook, rename this file to "pre-applypatch". + +. git-sh-setup +test -x "$GIT_DIR/hooks/pre-commit" && + exec "$GIT_DIR/hooks/pre-commit" ${1+"$@"} +: -- 1.7.8.rc0.61.g8a042