From 773f540d747c8ee6c5f56261395f7b4634acbbaa Mon Sep 17 00:00:00 2001 From: liuhaitao Date: Thu, 16 Apr 2020 15:18:24 +0800 Subject: [PATCH] tools/checkpatch.sh: enhance added files judgement with +++ at the line beginning In https://github.com/apache/incubator-nuttx-apps/pull/179, there is a removed graphics/littlevgl/lv_symbol_def.patch file whose content would be treated abnormally and results in errors. Signed-off-by: liuhaitao --- tools/checkpatch.sh | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/tools/checkpatch.sh b/tools/checkpatch.sh index 3fbc5598603..18a9848a6c1 100755 --- a/tools/checkpatch.sh +++ b/tools/checkpatch.sh @@ -56,7 +56,7 @@ check_file() { check_ranges() { while read; do - if [[ $REPLY =~ \+\+\+\ (b/)?([^[:blank:]]+).* ]]; then + if [[ $REPLY =~ ^(\+\+\+\ (b/)?([^[:blank:]]+).*)$ ]]; then if [ "$ranges" != "" ]; then if [ $range != 0 ]; then check_file $ranges $path 2>&1 @@ -64,7 +64,7 @@ check_ranges() { check_file $path 2>&1 fi fi - path=${BASH_REMATCH[2]} + path=${BASH_REMATCH[3]} ranges="" elif [[ $REPLY =~ @@\ -[0-9]+(,[0-9]+)?\ \+([0-9]+,[0-9]+)?\ @@.* ]]; then ranges+="-r ${BASH_REMATCH[2]} "