You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@nuttx.apache.org by gn...@apache.org on 2020/02/17 14:18:59 UTC
[incubator-nuttx] branch master updated: tools/checkpatch.sh: do
full file check for commits and patches defaultly
This is an automated email from the ASF dual-hosted git repository.
gnutt pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/incubator-nuttx.git
The following commit(s) were added to refs/heads/master by this push:
new 05391da tools/checkpatch.sh: do full file check for commits and patches defaultly
05391da is described below
commit 05391da6b87a59327c4456eb94d320ec1f868c1b
Author: liuhaitao <li...@xiaomi.com>
AuthorDate: Fri Feb 14 19:21:05 2020 +0800
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.
---
tools/checkpatch.sh | 34 +++++++++++++++++++++++++---------
1 file changed, 25 insertions(+), 9 deletions(-)
diff --git a/tools/checkpatch.sh b/tools/checkpatch.sh
index 2aaf188..3b54d42 100755
--- a/tools/checkpatch.sh
+++ b/tools/checkpatch.sh
@@ -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