Skip to content

Instantly share code, notes, and snippets.

@rpq
Created May 3, 2012 13:42
Show Gist options
  • Save rpq/2585732 to your computer and use it in GitHub Desktop.
Save rpq/2585732 to your computer and use it in GitHub Desktop.
git pre-commit hook: windows character (^M - ctrl-v ctrl-m) check
59 CTRL_M=`git status | grep modified | awk -F" " '{print $3}' | xargs -I '{}' grep -nPH "^M$" {}`
60 CTRL_M_COUNT=`echo "$CTRL_M" | wc -w`
61 if [ "$CTRL_M_COUNT" != "0" ]; then
62 echo "$CTRL_M" | xargs -I '{}' echo ">> git pre-commit hook: CTRL-M in {}"
63 exit 1
64 fi
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment