maint: add rule to ensure that our commit hook copies are up to date
authorJim Meyering <meyering@redhat.com>
Sat, 12 Nov 2011 21:23:09 +0000 (22:23 +0100)
committerJim Meyering <meyering@redhat.com>
Sat, 12 Nov 2011 21:23:09 +0000 (22:23 +0100)
* 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
scripts/git-hooks/pre-applypatch [new file with mode: 0755]

index 1ec2b36..716cbdd 100644 (file)
@@ -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 (executable)
index 0000000..b1f187c
--- /dev/null
@@ -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+"$@"}
+: