From ae4412b2fce137da592846d0559ad7f9df1c53c7 Mon Sep 17 00:00:00 2001 From: Lubomir Rintel Date: Mon, 4 Oct 2021 11:24:06 +0200 Subject: [PATCH] contrib/checkpatch: recognize git subtree merges Make checkpatch.pl identify subtree merges in "git am"-formatted patches and reconstruct the full path names based in the subtree root. This fixes some spurious warnings for parts of the tree that use different coding style from what we usually do. https://gitlab.freedesktop.org/NetworkManager/NetworkManager/-/merge_requests/989 --- contrib/scripts/checkpatch.pl | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/contrib/scripts/checkpatch.pl b/contrib/scripts/checkpatch.pl index 8ec581b543..330f452c13 100755 --- a/contrib/scripts/checkpatch.pl +++ b/contrib/scripts/checkpatch.pl @@ -1,7 +1,7 @@ #!/usr/bin/perl -n # SPDX-License-Identifier: GPL-2.0-or-later # -# Copyright (C) 2018 Red Hat, Inc. +# Copyright (C) 2018,2021 Red Hat, Inc. # # $ perldoc checkpatch.pl for eye-pleasing view of the manual: @@ -50,6 +50,7 @@ our $line_no; our $indent; our $check_is_todo; our $expect_spdx; +our $subdir; sub new_hunk { @@ -61,7 +62,8 @@ sub new_file { $expect_spdx = 0; $check_is_todo = 1; - $filename = shift; + $filename = $subdir // ''; + $filename .= shift; @functions_seen = (); } @@ -140,6 +142,7 @@ if ($is_patch) { /^(Reverts|Fixes): *(.*)/ and check_commit ($2, 1); /This reverts commit/ and next; /cherry picked from/ and next; + /^git-subtree-dir: (.*)/ and $subdir = "$1/"; /\bcommit (.*)/ and check_commit ($1, 0); next; } else { @@ -291,7 +294,7 @@ F =head1 COPYRIGHT -Copyright (C) 2018 Red Hat +Copyright (C) 2018,2021 Red Hat This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by