tools/checkpatch.sh: do full file check for commits and patches defaultly

Make 'checkpatch.sh -c commits' and 'checkpatch.sh -p patches' do full
file check as default, while 'checkpatch.sh -r -c commits' and 'checkpatch.sh
-r -p patches' do ranges check only.
This commit is contained in:
liuhaitao 2020-02-14 19:21:05 +08:00 committed by Gregory Nutt
parent ea72d84c4d
commit 05391da6b8

View File

@ -19,12 +19,14 @@
TOOLDIR=$(dirname $0)
fail=0
range=0
usage() {
echo "USAGE: ${0} [options] [list|-]"
echo ""
echo "Options:"
echo "-h"
echo "-r range check only (used with -p and -c)"
echo "-p <patch list> (default)"
echo "-c <commit list>"
echo "-f <file list>"
@ -44,7 +46,11 @@ check_ranges() {
while read; do
if [[ $REPLY =~ \+\+\+\ (b/)?([^[:blank:]]+).* ]]; then
if [ "$ranges" != "" ]; then
check_file $ranges $path 2>&1
if [ $range != 0 ]; then
check_file $ranges $path 2>&1
else
check_file $path 2>&1
fi
fi
path=${BASH_REMATCH[2]}
ranges=""
@ -53,19 +59,25 @@ check_ranges() {
fi
done
if [ "$ranges" != "" ]; then
check_file $ranges $path 2>&1
if [ $range != 0 ]; then
check_file $ranges $path 2>&1
else
check_file $path 2>&1
fi
fi
}
check_patch() {
git apply --check $1
if [ $? != 0 ]; then
exit 1
ret=$?
if [ $ret != 0 ]; then
fail=$ret
else
git apply $1
diffs=`cat $1`
check_ranges <<< "$diffs"
git apply -R $1
fi
git apply $1
diffs=`cat $1`
check_ranges <<< "$diffs"
git apply -R $1
}
check_commit() {
@ -86,6 +98,9 @@ while [ ! -z "$1" ]; do
usage
exit 0
;;
-r )
range=1
;;
-p )
shift
patches=$@
@ -103,13 +118,14 @@ while [ ! -z "$1" ]; do
;;
- )
check_ranges
exit 0
break
;;
* )
patches=$@
break
;;
esac
shift
done
for patch in $patches; do