Permalink
Browse files

Setup build framework.

Added Makefile and sample files. Install to appropriate location with a
default template for git init.
  • Loading branch information...
1 parent 871cafc commit be0cff30f2c6d1bed4f12f1a0b9a6158e8747e6e @bmeurer committed Nov 20, 2009
Showing with 83 additions and 2 deletions.
  1. +13 −0 .gitignore
  2. +41 −0 Makefile
  3. +2 −0 config.in
  4. +1 −0 description
  5. +6 −0 exclude
  6. +4 −2 git-generic-hook.c
  7. +16 −0 hook.in
View
@@ -0,0 +1,13 @@
+git-generic-hook
+config
+applypatch-msg
+commit-msg
+post-commit
+post-receive
+post-update
+pre-applypatch
+pre-commit
+pre-rebase
+prepare-commit-msg
+update
+
View
@@ -0,0 +1,41 @@
+# Makefile for git-generic-hooks
+#
+# Copyright (c) 2009 Benedikt Meurer <benedikt.meurer@googlemail.com>
+#
+
+CC=gcc
+CFLAGS=-O2 -Wall -Werror
+PREFIX=/usr/local
+
+HOOKS= applypatch-msg commit-msg post-commit post-receive post-update \
+ pre-applypatch pre-commit pre-rebase prepare-commit-msg update
+
+all: git-generic-hook config $(HOOKS)
+
+install: all
+ install -d -m 0755 $(PREFIX)/bin
+ install -c -m 0755 -s git-generic-hook $(PREFIX)/bin/git-generic-hook
+ install -d -m 755 $(PREFIX)/share/git-generic-hooks/templates
+ install -c -m 0644 config $(PREFIX)/share/git-generic-hooks/templates/config
+ install -c -m 0644 description $(PREFIX)/share/git-generic-hooks/templates/description
+ install -d -m 0755 $(PREFIX)/share/git-generic-hooks/templates/hooks
+ @for hook in $(HOOKS); do \
+ install -d -m 0755 "$(PREFIX)/share/git-generic-hooks/$${hook}.d"; \
+ install -c -m 0755 "$${hook}" "$(PREFIX)/share/git-generic-hooks/templates/hooks/$${hook}"; \
+ done
+ install -d -m 0755 $(PREFIX)/share/git-generic-hooks/templates/info
+ install -c -m 0644 exclude $(PREFIX)/share/git-generic-hooks/templates/info/exclude
+
+git-generic-hook: git-generic-hook.c
+ $(CC) $(CFLAGS) -o $@ $<
+
+config: config.in
+ sed -e "s,@PREFIX@,${PREFIX},g" < $< > $@
+
+$(HOOKS): hook.in
+ sed -e "s,@PREFIX@,${PREFIX},g" -e "s,@HOOK@,${@},g" < $< > $@
+
+clean:
+ rm -f git-generic-hook
+ rm -f config
+ rm -f $(HOOKS)
View
@@ -0,0 +1,2 @@
+[hooks]
+ basedir = @PREFIX@/share/git-generic-hooks
View
@@ -0,0 +1 @@
+Unnamed repository; edit this file 'description' to name the repository.
View
@@ -0,0 +1,6 @@
+# git-ls-files --others --exclude-from=.git/info/exclude
+# Lines that start with '#' are comments.
+# For a project mostly in C, the following would be a good set of
+# exclude patterns (uncomment them if you want to use them):
+# *.[oa]
+# *~
View
@@ -1,5 +1,7 @@
-/**
- * TODO
+/*-
+ * Generic Git hook program, which runs hooks from <basedir>/<hookname>.d/, where <basedir> is queried from the
+ * hooks.basedir property of the repository and <hookname> is the name of the hook (i.e. post-update). You need
+ * to either symlink or hardlink the resulting binary to all hooknames that you want to handle this way.
*
* Copyright (c) 2009 Benedikt Meurer <benedikt.meurer@googlemail.com>
*/
View
16 hook.in
@@ -0,0 +1,16 @@
+#!/bin/bash
+#
+# An example @HOOK@ script, which runs all hooks in
+#
+# <basedir>/@HOOK@.d/
+#
+# using the
+#
+# @PREFIX@/bin/git-generic-hook,
+#
+# where <basedir> is the hooks.basedir property set for this repository.
+#
+# Copyright (c) 2009 Benedikt Meurer <benedikt.meurer@googlemail.com>
+#
+
+exec -a "@HOOK@" "@PREFIX@/bin/git-generic-hook" "$@"

0 comments on commit be0cff3

Please sign in to comment.