diff --git a/tools/checkpatch.sh b/tools/checkpatch.sh index 3b54d42b6d..45303dd238 100755 --- a/tools/checkpatch.sh +++ b/tools/checkpatch.sh @@ -20,15 +20,17 @@ TOOLDIR=$(dirname $0) fail=0 range=0 +spell=0 usage() { echo "USAGE: ${0} [options] [list|-]" echo "" echo "Options:" echo "-h" - echo "-r range check only (used with -p and -c)" + echo "-c spell check with codespell(install with: pip install codespell" + echo "-r range check only (used with -p and -g)" echo "-p (default)" - echo "-c " + echo "-g " echo "-f " echo "- read standard input mainly used by git pre-commit hook as below:" echo " git diff --cached | ./tools/checkpatch.sh -" @@ -40,6 +42,14 @@ check_file() { if [ $ret != 0 ]; then fail=$ret fi + + if [ $spell != 0 ]; then + codespell -q 7 ${@: -1} + ret=$? + if [ $ret != 0 ]; then + fail=$ret + fi + fi } check_ranges() { @@ -98,6 +108,9 @@ while [ ! -z "$1" ]; do usage exit 0 ;; + -c ) + spell=1 + ;; -r ) range=1 ;; @@ -106,7 +119,7 @@ while [ ! -z "$1" ]; do patches=$@ break ;; - -c ) + -g ) shift commits=$@ break