Skip to content

Commit 34e9c88

Browse files
committed
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.
1 parent 35c5946 commit 34e9c88

23 files changed

+610
-484
lines changed

.gitignore

Lines changed: 1 addition & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1 @@
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-
1+
.*.swp

CMakeLists.txt

Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
project(git-hooks C)
2+
3+
# default to Debug builds
4+
if(NOT CMAKE_BUILD_TYPE)
5+
set(CMAKE_BUILD_TYPE Debug)
6+
endif(NOT CMAKE_BUILD_TYPE)
7+
8+
# disable assertions for non-debug builds
9+
if(NOT CMAKE_BUILD_TYPE MATCHES Debug)
10+
add_definitions(-DNDEBUG)
11+
endif(NOT CMAKE_BUILD_TYPE MATCHES Debug)
12+
13+
# set minimum CMake version
14+
cmake_minimum_required(VERSION 2.4)
15+
16+
# check for certain header files
17+
include(CheckIncludeFile)
18+
check_include_file(ctype.h HAVE_CTYPE_H)
19+
check_include_file(dirent.h HAVE_DIRENT_H)
20+
check_include_file(errno.h HAVE_ERRNO_H)
21+
check_include_file(signal.h HAVE_SIGNAL_H)
22+
check_include_file(stdarg.h HAVE_STDARG_H)
23+
check_include_file(stdio.h HAVE_STDIO_H)
24+
check_include_file(stdlib.h HAVE_STDLIB_H)
25+
check_include_file(string.h HAVE_STRING_H)
26+
check_include_file(sys/wait.h HAVE_SYS_WAIT_H)
27+
check_include_file(sys/types.h HAVE_SYS_TYPES_H)
28+
check_include_file(unistd.h HAVE_UNISTD_H)
29+
30+
# generate config.h from config.h.in
31+
configure_file(config.h.in config.h)
32+
33+
# force inclusion of config.h
34+
add_definitions(-DHAVE_CONFIG_H)
35+
include_directories("${CMAKE_CURRENT_BINARY_DIR}")
36+
37+
# GNU C compiler flags
38+
if(CMAKE_COMPILER_IS_GNUCC)
39+
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -O2 -Wall -Werror -Wextra -Winit-self -Wredundant-decls -Wformat-nonliteral -Wformat-security -Wswitch-enum -Wundef")
40+
endif(CMAKE_COMPILER_IS_GNUCC)
41+
42+
# build and install the git-run-hooks program
43+
add_executable(git-run-hooks git-run-hooks.c)
44+
install(TARGETS git-run-hooks
45+
DESTINATION bin)
46+
47+
add_subdirectory(hooks)
48+
add_subdirectory(template)

Makefile

Lines changed: 0 additions & 44 deletions
This file was deleted.

config.h.in

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
#ifndef __CONFIG_H__
2+
#define __CONFIG_H__
3+
4+
/* check for certain header files */
5+
#cmakedefine HAVE_CTYPE_H
6+
#cmakedefine HAVE_DIRENT_H
7+
#cmakedefine HAVE_ERRNO_H
8+
#cmakedefine HAVE_SIGNAL_H
9+
#cmakedefine HAVE_STDARG_H
10+
#cmakedefine HAVE_STDIO_H
11+
#cmakedefine HAVE_STDLIB_H
12+
#cmakedefine HAVE_STRING_H
13+
#cmakedefine HAVE_SYS_TYPES_H
14+
#cmakedefine HAVE_SYS_WAIT_H
15+
#cmakedefine HAVE_UNISTD_H
16+
17+
#endif /* !__CONFIG_H__ */

config.in

Lines changed: 0 additions & 2 deletions
This file was deleted.

0 commit comments

Comments
 (0)