[PATCH] checkpatch: Ignore symbolic links

Philipp Hahn posted 1 patch 3 weeks, 1 day ago
scripts/checkpatch.pl | 9 +++++++--
1 file changed, 7 insertions(+), 2 deletions(-)
[PATCH] checkpatch: Ignore symbolic links
Posted by Philipp Hahn 3 weeks, 1 day ago
If a commit adds a symbolic link, the target file name is stored as the
content:

> diff --git a/include/dt-bindings/clock/qcom,sm8650-dispcc.h \
>            b/include/dt-bindings/clock/qcom,sm8650-dispcc.h
> new file mode 120000
> index 0000000000000..c0a291188f28f
> --- /dev/null
> +++ b/include/dt-bindings/clock/qcom,sm8650-dispcc.h
> @@ -0,0 +1 @@
> +qcom,sm8550-dispcc.h
> \ No newline at end of file

checkpatch handles this as a normal patch and issues 2 warnings:

> $ scripts/checkpatch.pl --no-summary --terse --show-types \
>   --git v6.11-rc1-1-g99447ef003d19
> …:136: WARNING:SPDX_LICENSE_TAG: Missing or malformed \
>        SPDX-License-Identifier tag in line 1
> …:136: WARNING:MISSING_EOF_NEWLINE: adding a line without newline \
>        at end of file

Detect hunks, which add a symbolic link and ignore their content.

Signed-off-by: Philipp Hahn <phahn-oss@avm.de>
---
 scripts/checkpatch.pl | 9 +++++++--
 1 file changed, 7 insertions(+), 2 deletions(-)

diff --git a/scripts/checkpatch.pl b/scripts/checkpatch.pl
index 8a7787d228a63..1a875e0d8b084 100755
--- a/scripts/checkpatch.pl
+++ b/scripts/checkpatch.pl
@@ -2692,6 +2692,7 @@ sub process {
 	my $author_sob = '';
 	my $is_patch = 0;
 	my $is_binding_patch = -1;
+	my $is_symlink = 0;
 	my $in_header_lines = $file ? 0 : 1;
 	my $in_commit_log = 0;		#Scanning lines before patch
 	my $has_patch_separator = 0;	#Found a --- line
@@ -2904,6 +2905,7 @@ sub process {
 			$realfile = $1;
 			$realfile =~ s@^([^/]*)/@@ if (!$file);
 			$in_commit_log = 0;
+			$is_symlink = 0;
 			$found_file = 1;
 		} elsif ($line =~ /^\+\+\+\s+(\S+)/) {
 			$realfile = $1;
@@ -3493,6 +3495,9 @@ sub process {
 			     "added, moved or deleted file(s), does MAINTAINERS need updating?\n" . $herecurr);
 		}
 
+# Check for symbolic link
+		$is_symlink = 1 if (!$in_commit_log && ($line =~ /^new file mode\s*120000\s*$/));  # S_IFLNK
+
 # Check for adding new DT bindings not in schema format
 		if (!$in_commit_log &&
 		    ($line =~ /^new file mode\s*\d+\s*$/) &&
@@ -3646,8 +3651,8 @@ sub process {
 			}
 		}
 
-# ignore non-hunk lines and lines being removed
-		next if (!$hunk_line || $line =~ /^-/);
+# ignore non-hunk lines and lines being removed and symbolic links
+		next if (!$hunk_line || $line =~ /^-/ || $is_symlink);
 
 #trailing whitespace
 		if ($line =~ /^\+.*\015/) {
-- 
2.43.0