pre-commit 932 B

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