From: Jeff Johnson <jeff.johnson@oss.qualcomm.com>
To: Hendrik Hamerlinck <hendrik.hamerlinck@hammernet.be>,
dwaipayanray1@gmail.com, lukas.bulwahn@gmail.com,
joe@perches.com, corbet@lwn.net, apw@canonical.com
Cc: skhan@linuxfoundation.org, linux-kernel-mentees@lists.linux.dev,
workflows@vger.kernel.org, linux-doc@vger.kernel.org,
linux-kernel@vger.kernel.org
Subject: Re: [PATCH] checkpatch: validate commit tag ordering
Date: Thu, 24 Jul 2025 12:10:41 -0700 [thread overview]
Message-ID: <51eab1fa-5ea6-41f2-8b5b-fc5c16a9bca3@oss.qualcomm.com> (raw)
In-Reply-To: <20250724072032.118554-1-hendrik.hamerlinck@hammernet.be>
On 7/24/2025 12:20 AM, Hendrik Hamerlinck wrote:
> Modified the checkpatch script to ensure that commit tags (e.g.,
> Signed-off-by, Reviewed-by, Acked-by, Tested-by, etc.) appear in the
> correct order according to kernel conventions [1].
>
> checkpatch.pl will now emit a BAD_TAG_ORDER warning when tags are out of
> the expected sequence. Multiple tags of the same type are allowed, but
> they must also follow the order. 'Link:' tags in the changelog are still
> allowed before the tag sequence begins, but once the sequence has started,
> any 'Link:' tags must follow the ordered commit tags.
>
> Link: https://www.kernel.org/doc/html/latest/process/maintainer-tip.html#ordering-of-commit-tags # [1]
>
> Signed-off-by: Hendrik Hamerlinck <hendrik.hamerlinck@hammernet.be>
> ---
> Documentation/dev-tools/checkpatch.rst | 6 ++++
> scripts/checkpatch.pl | 40 ++++++++++++++++++++++++++
> 2 files changed, 46 insertions(+)
>
> diff --git a/Documentation/dev-tools/checkpatch.rst b/Documentation/dev-tools/checkpatch.rst
> index 76bd0ddb0041..696b42bf4ff5 100644
> --- a/Documentation/dev-tools/checkpatch.rst
> +++ b/Documentation/dev-tools/checkpatch.rst
> @@ -599,6 +599,12 @@ Commit message
>
> See: https://www.kernel.org/doc/html/latest/process/submitting-patches.html#describe-your-changes
>
> + **BAD_TAG_ORDER**
> + The tags in the commit message are not in the correct order according to
> + community conventions. Common tags like Signed-off-by, Reviewed-by,
> + Tested-by, Acked-by, Fixes, Cc, etc., should follow a standardized sequence.
> +
> + See: https://www.kernel.org/doc/html/latest/process/maintainer-tip.html#ordering-of-commit-tags
>
> Comparison style
> ----------------
> diff --git a/scripts/checkpatch.pl b/scripts/checkpatch.pl
> index 664f7b7a622c..267ec02de9ec 100755
> --- a/scripts/checkpatch.pl
> +++ b/scripts/checkpatch.pl
> @@ -661,6 +661,24 @@ foreach my $entry (@link_tags) {
> }
> $link_tags_search = "(?:${link_tags_search})";
>
> +# Ordered commit tags
> +our @commit_tags = (
> + "Fixes:",
> + "Reported-by:",
> + "Closes:",
> + "Originally-by:",
> + "Suggested-by:",
> + "Co-developed-by:",
> + "Signed-off-by:",
> + "Tested-by:",
> + "Reviewed-by",
> + "Acked-by:",
> + "Cc:",
> + "Link:"
> +);
> +our $commit_tag_pattern = join '|', map { quotemeta($_) } @commit_tags;
> +our $commit_tags_regex = qr{(?xi: ^\s*($commit_tag_pattern))};
> +
> our $tracing_logging_tags = qr{(?xi:
> [=-]*> |
> <[=-]* |
> @@ -2712,6 +2730,8 @@ sub process {
>
> my $checklicenseline = 1;
>
> + my $last_matched_tag;
> +
> sanitise_line_reset();
> my $line;
> foreach my $rawline (@rawlines) {
> @@ -3258,6 +3278,26 @@ sub process {
> }
> }
>
> +# Check commit tags sorting
> + if (!$in_header_lines && $line =~ $commit_tags_regex) {
> + my $tag = $1;
> + my ($tag_index) = grep { lc($commit_tags[$_]) eq lc($tag) } 0..$#commit_tags;
> +
> + if ($last_matched_tag &&
> + $last_matched_tag->{tag_index} > $tag_index) {
> + WARN("BAD_TAG_ORDER",
> + "Tag '$tag' is out of order. Should come before '$last_matched_tag->{tag}'\n" . $herecurr);
> + }
> +
> + # Allow link tags to occur before the commit tags
> + if (lc($tag) ne "link:" || defined $last_matched_tag) {
> + $last_matched_tag = {
> + tag => $tag,
> + tag_index => $tag_index,
> + };
> + }
> + }
> +
> # Check email subject for common tools that don't need to be mentioned
> if ($in_header_lines &&
> $line =~ /^Subject:.*\b(?:checkpatch|sparse|smatch)\b[^:]/i) {
Seems this logic would fail when there are multiple reporters, such as in
commit 9a44b5e36cd699fdd2150a63fab225ac510c1971
Fixes: 49e47223ecc4 ("wifi: cfg80211: allocate memory for link_station info structure")
Reported-by: Dan Carpenter <dan.carpenter@linaro.org>
Closes: https://lore.kernel.org/all/81f30515-a83d-4b05-a9d1-e349969df9e9@sabinyo.mountain/
Reported-by: syzbot+4ba6272678aa468132c8@syzkaller.appspotmail.com
Closes: https://lore.kernel.org/all/68655325.a70a0220.5d25f.0316.GAE@google.com
next prev parent reply other threads:[~2025-07-24 19:10 UTC|newest]
Thread overview: 11+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-07-24 7:20 [PATCH] checkpatch: validate commit tag ordering Hendrik Hamerlinck
2025-07-24 15:04 ` Akira Yokosawa
2025-07-24 19:10 ` Jeff Johnson [this message]
2025-07-24 19:43 ` Konstantin Ryabitsev
2025-07-25 8:42 ` Krzysztof Kozlowski
2025-07-31 11:55 ` Geert Uytterhoeven
2025-07-31 12:46 ` Krzysztof Kozlowski
2025-08-01 7:55 ` Jani Nikula
2025-08-02 10:12 ` Mauro Carvalho Chehab
2025-08-02 16:26 ` Konstantin Ryabitsev
2025-07-26 7:34 ` Hendrik Hamerlinck
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=51eab1fa-5ea6-41f2-8b5b-fc5c16a9bca3@oss.qualcomm.com \
--to=jeff.johnson@oss.qualcomm.com \
--cc=apw@canonical.com \
--cc=corbet@lwn.net \
--cc=dwaipayanray1@gmail.com \
--cc=hendrik.hamerlinck@hammernet.be \
--cc=joe@perches.com \
--cc=linux-doc@vger.kernel.org \
--cc=linux-kernel-mentees@lists.linux.dev \
--cc=linux-kernel@vger.kernel.org \
--cc=lukas.bulwahn@gmail.com \
--cc=skhan@linuxfoundation.org \
--cc=workflows@vger.kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).