Skip to content

Commit be0cff3

Browse files
committed
Setup build framework.
Added Makefile and sample files. Install to appropriate location with a default template for git init.
1 parent 871cafc commit be0cff3

File tree

7 files changed

+83
-2
lines changed

7 files changed

+83
-2
lines changed

.gitignore

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
git-generic-hook
2+
config
3+
applypatch-msg
4+
commit-msg
5+
post-commit
6+
post-receive
7+
post-update
8+
pre-applypatch
9+
pre-commit
10+
pre-rebase
11+
prepare-commit-msg
12+
update
13+

Makefile

Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
# Makefile for git-generic-hooks
2+
#
3+
# Copyright (c) 2009 Benedikt Meurer <benedikt.meurer@googlemail.com>
4+
#
5+
6+
CC=gcc
7+
CFLAGS=-O2 -Wall -Werror
8+
PREFIX=/usr/local
9+
10+
HOOKS= applypatch-msg commit-msg post-commit post-receive post-update \
11+
pre-applypatch pre-commit pre-rebase prepare-commit-msg update
12+
13+
all: git-generic-hook config $(HOOKS)
14+
15+
install: all
16+
install -d -m 0755 $(PREFIX)/bin
17+
install -c -m 0755 -s git-generic-hook $(PREFIX)/bin/git-generic-hook
18+
install -d -m 755 $(PREFIX)/share/git-generic-hooks/templates
19+
install -c -m 0644 config $(PREFIX)/share/git-generic-hooks/templates/config
20+
install -c -m 0644 description $(PREFIX)/share/git-generic-hooks/templates/description
21+
install -d -m 0755 $(PREFIX)/share/git-generic-hooks/templates/hooks
22+
@for hook in $(HOOKS); do \
23+
install -d -m 0755 "$(PREFIX)/share/git-generic-hooks/$${hook}.d"; \
24+
install -c -m 0755 "$${hook}" "$(PREFIX)/share/git-generic-hooks/templates/hooks/$${hook}"; \
25+
done
26+
install -d -m 0755 $(PREFIX)/share/git-generic-hooks/templates/info
27+
install -c -m 0644 exclude $(PREFIX)/share/git-generic-hooks/templates/info/exclude
28+
29+
git-generic-hook: git-generic-hook.c
30+
$(CC) $(CFLAGS) -o $@ $<
31+
32+
config: config.in
33+
sed -e "s,@PREFIX@,${PREFIX},g" < $< > $@
34+
35+
$(HOOKS): hook.in
36+
sed -e "s,@PREFIX@,${PREFIX},g" -e "s,@HOOK@,${@},g" < $< > $@
37+
38+
clean:
39+
rm -f git-generic-hook
40+
rm -f config
41+
rm -f $(HOOKS)

config.in

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
[hooks]
2+
basedir = @PREFIX@/share/git-generic-hooks

description

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
Unnamed repository; edit this file 'description' to name the repository.

exclude

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
# git-ls-files --others --exclude-from=.git/info/exclude
2+
# Lines that start with '#' are comments.
3+
# For a project mostly in C, the following would be a good set of
4+
# exclude patterns (uncomment them if you want to use them):
5+
# *.[oa]
6+
# *~

git-generic-hook.c

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
1-
/**
2-
* TODO
1+
/*-
2+
* Generic Git hook program, which runs hooks from <basedir>/<hookname>.d/, where <basedir> is queried from the
3+
* hooks.basedir property of the repository and <hookname> is the name of the hook (i.e. post-update). You need
4+
* to either symlink or hardlink the resulting binary to all hooknames that you want to handle this way.
35
*
46
* Copyright (c) 2009 Benedikt Meurer <benedikt.meurer@googlemail.com>
57
*/

hook.in

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
#!/bin/bash
2+
#
3+
# An example @HOOK@ script, which runs all hooks in
4+
#
5+
# <basedir>/@HOOK@.d/
6+
#
7+
# using the
8+
#
9+
# @PREFIX@/bin/git-generic-hook,
10+
#
11+
# where <basedir> is the hooks.basedir property set for this repository.
12+
#
13+
# Copyright (c) 2009 Benedikt Meurer <benedikt.meurer@googlemail.com>
14+
#
15+
16+
exec -a "@HOOK@" "@PREFIX@/bin/git-generic-hook" "$@"

0 commit comments

Comments
 (0)