pre-commit 582 B

1234567891011121314151617181920212223
  1. #!/bin/sh
  2. #check the config, in case the user really wants to allow tabs...
  3. allowtabs=$(git config hooks.allowtabs)
  4. if [ "$allowtabs" != "true" ] &&
  5. git diff --cached | egrep '^\+.* '
  6. then
  7. cat<<END;
  8. Error: This commit would contain a tab, which is against this repo's policy.
  9. END
  10. exit 1
  11. fi
  12. # If there are whitespace errors, print the offending file names and fail.
  13. if
  14. # Use git built-in checks for trailing whitespaces
  15. ! git diff --check --cached
  16. then
  17. cat<<END;
  18. Error: This commit would contain trailing spaces, which is against this repo's policy.
  19. END
  20. exit 1
  21. fi