I\'m writing a git pre-commit hook to check if any of the staged files are containing disallowed text and abort if that\'s the case.
Not an expert at this. So far I\
Answer to mark this question as having an answer:
OP ended up with:
disallowed="word1 word2"
git diff --cached --name-status | while read x file; do
if [ "$x" == 'D' ]; then continue; fi
for word in $disallowed
do
if egrep $word $file ; then
echo "ERROR: Disallowed expression \"${word}\" in file: ${file}"
exit 1
fi
done
done || exit $?