summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--.gitconfig2
-rw-r--r--CMakeLists.txt7
-rw-r--r--hooks/pre-commit23
3 files changed, 32 insertions, 0 deletions
diff --git a/.gitconfig b/.gitconfig
new file mode 100644
index 000000000..4cab7f2d9
--- /dev/null
+++ b/.gitconfig
@@ -0,0 +1,2 @@
1[core]
2 whitespace = blank-at-eol,trailing-space,tab-in-indent
diff --git a/CMakeLists.txt b/CMakeLists.txt
index fc742317c..d958dfc35 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -4,6 +4,13 @@ cmake_minimum_required(VERSION 2.8.11)
4 4
5project(citra) 5project(citra)
6 6
7if(NOT EXISTS ${CMAKE_CURRENT_SOURCE_DIR}/.git/hooks/pre-commit)
8 message(STATUS "Copying pre-commit hook")
9 file(COPY hooks/pre-commit
10 DESTINATION ${CMAKE_CURRENT_SOURCE_DIR}/.git/hooks
11 FILE_PERMISSIONS WORLD_EXECUTE )
12endif()
13
7if (NOT MSVC) 14if (NOT MSVC)
8 set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++11 -Wno-attributes -pthread") 15 set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++11 -Wno-attributes -pthread")
9 set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -pthread") 16 set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -pthread")
diff --git a/hooks/pre-commit b/hooks/pre-commit
new file mode 100644
index 000000000..44010fa1a
--- /dev/null
+++ b/hooks/pre-commit
@@ -0,0 +1,23 @@
1#!/bin/sh
2
3#check the config, in case the user really wants to allow tabs...
4allowtabs=$(git config hooks.allowtabs)
5if [ "$allowtabs" != "true" ] &&
6 git diff --cached | egrep '^\+.* '
7then
8 cat<<END;
9Error: This commit would contain a tab, which is against this repo's policy.
10END
11 exit 1
12fi
13
14# If there are whitespace errors, print the offending file names and fail.
15if
16# Use git built-in checks for trailing whitespaces
17 ! git diff --check --cached
18then
19 cat<<END;
20Error: This commit would contain trailing spaces, which is against this repo's policy.
21END
22 exit 1
23fi