checkpatch: warn for non-standard fixes tag style
Subsystems (4)
PATCH 1/1 checkpatch: warn for non-standard fixes tag style
Add a warning for fixes tags that does not fall in line with the standards specified by the community.
--- Documentation/dev-tools/checkpatch.rst | 6 ++++ scripts/checkpatch.pl | 41 ++++++++++++++++++++++++++ 2 files changed, 47 insertions(+)
Documentation/dev-tools/checkpatch.rst +6 -0
@@ -612,6 +612,12 @@ Commit message See: https://www.kernel.org/doc/html/latest/process/submitting-patches.html#describe-your-changes + **BAD_FIXES_TAG** + The fixes line does not fall in line with the standards specified by the + community. + + See: https://www.kernel.org/doc/html/latest/process/submitting-patches.html#describe-your-changes + Comparison style ----------------
scripts/checkpatch.pl +41 -0
47 lines not on this page · raw message
Signature · 1 line
2.37.2
Joe Perches
maintainerQuoted 38 lines · Niklas Söderlund
Add a warning for fixes tags that does not fall in line with the standards specified by the community.
Signed-off-by Niklas Söderlund <[email protected]>Reviewed-by Simon Horman <[email protected]>Reviewed-by Louis Peens <[email protected]>--- Documentation/dev-tools/checkpatch.rst | 6 ++++ scripts/checkpatch.pl | 41 ++++++++++++++++++++++++++ 2 files changed, 47 insertions(+)Documentation/dev-tools/checkpatch.rst +6
-0@@ -612,6 +612,12 @@ Commit message See: https://www.kernel.org/doc/html/latest/process/submitting-patches.html#describe-your-changes + **BAD_FIXES_TAG** + The fixes line does not fall in line with the standards specified by the + community. + + See: https://www.kernel.org/doc/html/latest/process/submitting-patches.html#describe-your-changes + Comparison style ----------------scripts/checkpatch.pl +2
-0@@ -3140,6 +3140,47 @@ sub process { } } +# Check Fixes: styles is correct + if (!$in_header_lines && $line =~ /^fixes:/i) {
scripts/checkpatch.pl sub process { · line 3154
Quoted 10 lines
scripts/checkpatch.pl +10
-0+ my $orig_commit = ""; + my $id = "0123456789ab"; + my $title = "commit title"; + my $tag_case = 1; + my $tag_space = 1; + my $id_length = 1; + my $id_case = 1; + my $title_has_quotes = 0; + + if ($line =~ /(fixes:)\s+([0-9a-f]{5,})\s+($balanced_parens)/i) {
Maybe use fixes:? so the colon is not required in poorly formed uses
scripts/checkpatch.pl sub process { · line 3160
Quoted 6 lines
scripts/checkpatch.pl +6
-0+ my $tag = $1; + $orig_commit = $2; + $title = $3; + + $tag_case = 0 if $tag eq "Fixes:"; + $tag_space = 0 if ($line =~ /^fixes: [0-9a-f]{5,} ($balanced_parens)/i);
Pity there's no simple way to consolidate this git commit test block with the existing git id commit block.
Quoted 26 lines
scripts/checkpatch.pl +23
-0+ + $id_length = 0 if ($orig_commit =~ /^[0-9a-f]{12}$/i); + $id_case = 0 if ($orig_commit !~ /[A-F]/); + + # Always strip leading/trailing parens then double quotes if existing + $title = substr($title, 1, -1); + if ($title =~ /^".*"$/) { + $title = substr($title, 1, -1); + $title_has_quotes = 1; + } + } + + ($id, $title) = git_commit_info($orig_commit, $id, + $title); + + if ($tag_case || $tag_space || $id_length || $id_case || + !$title_has_quotes) { + WARN("BAD_FIXES_TAG", + "Please use correct Fixes: style 'Fixes: <12 chars of sha1> (\"<title line>\")' - ie: 'Fixes: $id (\"$title\")'\n" . $herecurr); + + } + } + # 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) {
Hi Joe,
Thanks for your feedback.
Quoted 4 lines · Joe Perches
Quoted 2 lines
(quoted diff) +1
-0+ if ($line =~/(fixes:)\s+([0-9a-f]{5,})\s+($balanced_parens)/i) {
Maybe use fixes:? so the colon is not required in poorly formed uses
I tried that but I think it brings more problems then it is worth. With that change the check would run for each line of the commit message that begins with the string 'fixes', not just in the tags section of the message. So it would warn for the commit message,
The work on foo and bar introduced a bug that can be fixed by doing baz.
I think it's for this reason other checks for tags include the ':'.
Quoted 10 lines
scripts/checkpatch.pl sub process { · line 3160
Quoted 7 lines
scripts/checkpatch.pl +6
-0+ my $tag = $1; + $orig_commit = $2; + $title = $3; + + $tag_case = 0 if $tag eq "Fixes:"; + $tag_space = 0 if ($line =~ /^fixes: [0-9a-f]{5,} ($balanced_parens)/i);Fixes ? here too
Quoted 2 lines
Pity there's no simple way to consolidate this git commit test block with the existing git id commit block.
I agree.
Signature · 2 lines
Kind Regards, Niklas Söderlund
Joe Perches
maintainerQuoted 10 lines · Niklas Söderlund
Hi Joe,
Thanks for your feedback.
Quoted 4 lines · Joe Perches
Quoted 2 lines
(quoted diff) +1
-0+ if ($line =~/(fixes:)\s+([0-9a-f]{5,})\s+($balanced_parens)/i) {
Maybe use fixes:? so the colon is not required in poorly formed uses
Quoted 4 lines
I tried that but I think it brings more problems then it is worth. With that change the check would run for each line of the commit message that begins with the string 'fixes', not just in the tags section of the message. So it would warn for the commit message,
I think it's not a problem.
Look at the results of:
$ git log -100000 --no-merges --format=email --grep="^fixes" -i | \
grep -i -P -oh '^fixes:?\s*[0-9a-f]{5,}\s*..' | \
sed -r -e 's/^(fixes:?\s*)[0-9a-f]+/\1/i' | \
sort | uniq -c | sort -rn | head -20
73974 Fixes: ("
1345 Fixes: ('
399 Fixes:
246 Fixes: (A
215 Fixes: ("
172 Fixes: (c
121 Fixes: (s
114 Fixes: (d
110 Fixes: (P
98 Fixes: (i
90 Fixes: (m
86 Fixes: (n
78 Fixes: :
57 Fixes ("
51 Fixes: "n
47 Fixes: (a
46 Fixes: (t
43 fixes: ("
42 Fixes: (p
41 Fixes: ('Hello Joe,
Quoted 35 lines · Joe Perches
Quoted 10 lines · Niklas Söderlund
Hi Joe,
Thanks for your feedback.
Quoted 4 lines · Joe Perches
Quoted 2 lines
(quoted diff) +1
-0+ if ($line =~/(fixes:)\s+([0-9a-f]{5,})\s+($balanced_parens)/i) {
Maybe use fixes:? so the colon is not required in poorly formed uses
Quoted 4 lines
I tried that but I think it brings more problems then it is worth. With that change the check would run for each line of the commit message that begins with the string 'fixes', not just in the tags section of the message. So it would warn for the commit message,
I think it's not a problem.
Look at the results of:$ git log -100000 --no-merges --format=email --grep="^fixes" -i | \ grep -i -P -oh '^fixes:?\s*[0-9a-f]{5,}\s*..' | \ sed -r -e 's/^(fixes:?\s*)[0-9a-f]+/\1/i' | \ sort | uniq -c | sort -rn | head -20 73974 Fixes: (" 1345 Fixes: (' 399 Fixes: 246 Fixes: (A 215 Fixes: (" 172 Fixes: (c 121 Fixes: (s 114 Fixes: (d 110 Fixes: (P 98 Fixes: (i 90 Fixes: (m 86 Fixes: (n
Quoted 8 lines
78 Fixes: :
57 Fixes ("
51 Fixes: "n
47 Fixes: (a
46 Fixes: (t
43 fixes: ("
42 Fixes: (p
41 Fixes: ('Thanks for checking this. With this background I agree with you, there is no problem here. I will spin a v3 with your suggestion.
Quoted 1 line
Signature · 2 lines
Kind Regards, Niklas Söderlund
Documentation/dev-tools/checkpatch.rst Commit message · line 620
Quoted 7 lines · Niklas Söderlund
Documentation/dev-tools/checkpatch.rst +6
-0+ **BAD_FIXES_TAG** + The fixes line does not fall in line with the standards specified by the + community. + + See: https://www.kernel.org/doc/html/latest/process/submitting-patches.html#describe-your-changes +
Did you mean "The Fixes: tag is malformed"?
Also, mention that this message can occur when the tag is split into multiple lines (e.g., when pasted in email program with word wrapping enabled).
Thanks.
Signature · 1 line
An old man doll... just what I always wanted! - Clara