diff options
| -rw-r--r-- | .gitconfig | 2 | ||||
| -rw-r--r-- | CMakeLists.txt | 7 | ||||
| -rw-r--r-- | hooks/pre-commit | 23 |
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 | ||
| 5 | project(citra) | 5 | project(citra) |
| 6 | 6 | ||
| 7 | if(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 ) | ||
| 12 | endif() | ||
| 13 | |||
| 7 | if (NOT MSVC) | 14 | if (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... | ||
| 4 | allowtabs=$(git config hooks.allowtabs) | ||
| 5 | if [ "$allowtabs" != "true" ] && | ||
| 6 | git diff --cached | egrep '^\+.* ' | ||
| 7 | then | ||
| 8 | cat<<END; | ||
| 9 | Error: This commit would contain a tab, which is against this repo's policy. | ||
| 10 | END | ||
| 11 | exit 1 | ||
| 12 | fi | ||
| 13 | |||
| 14 | # If there are whitespace errors, print the offending file names and fail. | ||
| 15 | if | ||
| 16 | # Use git built-in checks for trailing whitespaces | ||
| 17 | ! git diff --check --cached | ||
| 18 | then | ||
| 19 | cat<<END; | ||
| 20 | Error: This commit would contain trailing spaces, which is against this repo's policy. | ||
| 21 | END | ||
| 22 | exit 1 | ||
| 23 | fi | ||