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
This commit is contained in:
Lubomir Rintel 2021-10-04 11:24:06 +02:00
parent e81c2baf70
commit ae4412b2fc

View file

@ -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<CONTRIBUTING>
=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