Skip to content

Instantly share code, notes, and snippets.

@m0tive
Created January 27, 2016 10:40
Show Gist options
  • Save m0tive/aa7a49e3706671bee42a to your computer and use it in GitHub Desktop.
Save m0tive/aa7a49e3706671bee42a to your computer and use it in GitHub Desktop.
#!/bin/bash
if git rev-parse --verify HEAD >/dev/null 2>&1
then
against=HEAD
else
# Initial commit: diff against an empty tree object
against=4b825dc642cb6eb9a060e54bf8d69288fbee4904
fi
ws_errors=$(git diff-index --check --cached $against -- 2>/dev/null | sed '/^[+-]/d' | grep '\.\(cpp\|h\|lua\):')
if [ -n "$ws_errors" ]; then
printf "$ws_errors"
echo
echo "ABORTING, whitespace errors"
exit 1
fi
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment