Skip to content

Instantly share code, notes, and snippets.

@malexw
Created January 11, 2013 19:39
Show Gist options
  • Save malexw/4513374 to your computer and use it in GitHub Desktop.
Save malexw/4513374 to your computer and use it in GitHub Desktop.
When installed as a git pre-commit hook, this script will prevent a commit from being created if the token '!DNC' is found within the diff.
#!/bin/sh
exec 1>&2
dnc_count=$(git diff --cached | grep -c '!DNC')
if [ "$dnc_count" != "0" ]
then
echo "Aborting commit. Found" $dnc_count "!DNC markers"
exit $dnc_count
fi
exit 0
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment