Permalink
Browse files

Rework git-generic-hooks to git-hooks.

Rename project to git-hooks. Rework build framework to use CMake instead of
GNU make. Restructure the C program to process the hooks. Add several
hook scripts.
  • Loading branch information...
1 parent 35c5946 commit 34e9c8848bc721d34035df4d43c2c5e8c711ade2 @bmeurer committed Nov 21, 2009
View
@@ -1,13 +1 @@
-git-generic-hook
-config
-applypatch-msg
-commit-msg
-post-commit
-post-receive
-post-update
-pre-applypatch
-pre-commit
-pre-rebase
-prepare-commit-msg
-update
-
+.*.swp
View
@@ -0,0 +1,48 @@
+project(git-hooks C)
+
+# default to Debug builds
+if(NOT CMAKE_BUILD_TYPE)
+ set(CMAKE_BUILD_TYPE Debug)
+endif(NOT CMAKE_BUILD_TYPE)
+
+# disable assertions for non-debug builds
+if(NOT CMAKE_BUILD_TYPE MATCHES Debug)
+ add_definitions(-DNDEBUG)
+endif(NOT CMAKE_BUILD_TYPE MATCHES Debug)
+
+# set minimum CMake version
+cmake_minimum_required(VERSION 2.4)
+
+# check for certain header files
+include(CheckIncludeFile)
+check_include_file(ctype.h HAVE_CTYPE_H)
+check_include_file(dirent.h HAVE_DIRENT_H)
+check_include_file(errno.h HAVE_ERRNO_H)
+check_include_file(signal.h HAVE_SIGNAL_H)
+check_include_file(stdarg.h HAVE_STDARG_H)
+check_include_file(stdio.h HAVE_STDIO_H)
+check_include_file(stdlib.h HAVE_STDLIB_H)
+check_include_file(string.h HAVE_STRING_H)
+check_include_file(sys/wait.h HAVE_SYS_WAIT_H)
+check_include_file(sys/types.h HAVE_SYS_TYPES_H)
+check_include_file(unistd.h HAVE_UNISTD_H)
+
+# generate config.h from config.h.in
+configure_file(config.h.in config.h)
+
+# force inclusion of config.h
+add_definitions(-DHAVE_CONFIG_H)
+include_directories("${CMAKE_CURRENT_BINARY_DIR}")
+
+# GNU C compiler flags
+if(CMAKE_COMPILER_IS_GNUCC)
+ set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -O2 -Wall -Werror -Wextra -Winit-self -Wredundant-decls -Wformat-nonliteral -Wformat-security -Wswitch-enum -Wundef")
+endif(CMAKE_COMPILER_IS_GNUCC)
+
+# build and install the git-run-hooks program
+add_executable(git-run-hooks git-run-hooks.c)
+install(TARGETS git-run-hooks
+ DESTINATION bin)
+
+add_subdirectory(hooks)
+add_subdirectory(template)
View
@@ -1,44 +0,0 @@
-# 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
- install -c -m 0755 post-receive.d/99gitnotify $(PREFIX)/share/git-generic-hooks/post-receive.d/99gitnotify
- install -c -m 0755 post-update.d/99updateserverinfo $(PREFIX)/share/git-generic-hooks/post-update.d/99updateserverinfo
- install -c -m 0755 update.d/10verify $(PREFIX)/share/git-generic-hooks/update.d/10verify
-
-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,17 @@
+#ifndef __CONFIG_H__
+#define __CONFIG_H__
+
+/* check for certain header files */
+#cmakedefine HAVE_CTYPE_H
+#cmakedefine HAVE_DIRENT_H
+#cmakedefine HAVE_ERRNO_H
+#cmakedefine HAVE_SIGNAL_H
+#cmakedefine HAVE_STDARG_H
+#cmakedefine HAVE_STDIO_H
+#cmakedefine HAVE_STDLIB_H
+#cmakedefine HAVE_STRING_H
+#cmakedefine HAVE_SYS_TYPES_H
+#cmakedefine HAVE_SYS_WAIT_H
+#cmakedefine HAVE_UNISTD_H
+
+#endif /* !__CONFIG_H__ */
View
@@ -1,2 +0,0 @@
-[hooks]
- basedir = @PREFIX@/share/git-generic-hooks
Oops, something went wrong.

0 comments on commit 34e9c88

Please sign in to comment.