Skip to content

Commit

Permalink
checkpatch: add option for excluding directories
Browse files Browse the repository at this point in the history
  • Loading branch information
sobuch authored and erhankur committed Dec 20, 2024
1 parent 9a1b68a commit 4b1e752
Show file tree
Hide file tree
Showing 3 changed files with 25 additions and 10 deletions.
10 changes: 10 additions & 0 deletions .checkpatch.conf
Original file line number Diff line number Diff line change
Expand Up @@ -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
12 changes: 2 additions & 10 deletions tools/checkpatch-esp.sh
Original file line number Diff line number Diff line change
@@ -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}..
13 changes: 13 additions & 0 deletions tools/scripts/checkpatch.pl
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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,
Expand Down Expand Up @@ -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: "
Expand Down

0 comments on commit 4b1e752

Please sign in to comment.