From 4b1e752c62c2634b53c7ab5173fa05833d0d7899 Mon Sep 17 00:00:00 2001 From: Samuel Obuch Date: Thu, 19 Dec 2024 13:51:18 +0100 Subject: [PATCH] checkpatch: add option for excluding directories --- .checkpatch.conf | 10 ++++++++++ tools/checkpatch-esp.sh | 12 ++---------- tools/scripts/checkpatch.pl | 13 +++++++++++++ 3 files changed, 25 insertions(+), 10 deletions(-) diff --git a/.checkpatch.conf b/.checkpatch.conf index 8cb9a3729a..054014b70b 100644 --- a/.checkpatch.conf +++ b/.checkpatch.conf @@ -27,3 +27,13 @@ --ignore SWITCH_CASE_INDENT_LEVEL --ignore TRACING_LOGGING --ignore VOLATILE + +# ESPRESSIF +--no-signoff +--ignore COMMIT_MESSAGE +--ignore UNKNOWN_COMMIT_ID +--exclude src/jtag/drivers/libjaylink +--exclude tools/git2cl +--exclude .gitlab +--exclude HACKING +--exclude testing/esp diff --git a/tools/checkpatch-esp.sh b/tools/checkpatch-esp.sh index f569077508..30beac7181 100755 --- a/tools/checkpatch-esp.sh +++ b/tools/checkpatch-esp.sh @@ -1,13 +1,5 @@ #!/bin/sh # SPDX-License-Identifier: GPL-2.0-or-later -cnt=$(git rev-list --count HEAD ^origin/master) -git diff HEAD~${cnt} \ - | filterdiff \ - -x "a/src/jtag/drivers/libjaylink/*" \ - -x "a/tools/git2cl/*" \ - -x "a/.gitlab/*" \ - -x "a/HACKING" \ - -x "a/testing/esp/*" \ - | ./tools/scripts/checkpatch.pl --no-signoff \ - --ignore FUNCTION_ARGUMENTS --ignore CAMELCASE --ignore LONG_LINE_STRING +since=${1:-origin/master} +tools/scripts/checkpatch.pl --git ${since}.. diff --git a/tools/scripts/checkpatch.pl b/tools/scripts/checkpatch.pl index 1011b33055..28296e21db 100755 --- a/tools/scripts/checkpatch.pl +++ b/tools/scripts/checkpatch.pl @@ -67,6 +67,7 @@ my @use = (); my %ignore_type = (); my @ignore = (); +my @exclude = (); my $help = 0; my $configuration_file = ".checkpatch.conf"; my $max_line_length = 100; @@ -123,6 +124,7 @@ sub help { --list-types list the possible message types --types TYPE(,TYPE2...) show only these comma separated message types --ignore TYPE(,TYPE2...) ignore various comma separated message types + --exclude DIR(,DIR2...) exclude directories --show-types show the specific message type in the output --max-line-length=n set the maximum line length, (default $max_line_length) if exceeded, warn on patches @@ -320,6 +322,7 @@ sub load_docs { 'subjective!' => \$check, 'strict!' => \$check, 'ignore=s' => \@ignore, + 'exclude=s' => \@exclude, 'types=s' => \@use, 'show-types!' => \$show_types, 'list-types!' => \$list_types, @@ -2930,6 +2933,16 @@ sub process { $found_file = 1; } + my $excluded = 0; + foreach (@exclude) { + if ($realfile =~ m@^(?:$_/)@) { + $excluded = 1; + } + } + if ($excluded) { + next; + } + #make up the handle for any error we report on this line if ($showfile) { $prefix = "$realfile:$realline: "