/ hooks / pre-commit
pre-commit
 1  #!/bin/sh
 2  
 3  # Enforce citra's whitespace policy
 4  git config --local core.whitespace tab-in-indent,trailing-space
 5  
 6  paths_to_check="src/ CMakeLists.txt"
 7  
 8  # If there are whitespace errors, print the offending file names and fail.
 9  if ! git diff --cached --check -- $paths_to_check ; then
10      cat<<END
11  
12  Error: This commit would contain trailing spaces or tabs, which is against this repo's policy.
13  Please correct those issues before committing. (Use 'git diff --check' for more details)
14  If you know what you are doing, you can try 'git commit --no-verify' to bypass the check
15  END
16      exit 1
17  fi
18  
19  # Check for tabs, since tab-in-indent catches only those at the beginning of a line
20  if git diff --cached -- $paths_to_check | egrep '^\+.*	'; then
21      cat<<END
22  Error: This commit would contain a tab, which is against this repo's policy.
23  If you know what you are doing, you can try 'git commit --no-verify' to bypass the check.
24  END
25      exit 1
26  fi