Ilya Maximets <[email protected]> writes:

> On 11/12/26 2:14 PM, Aaron Conole wrote:
>> Ilya Maximets via dev <[email protected]> writes:
>> 
>>> An mbox in many cases has the Subject line wrapped at 78 characters
>>> as suggested in RFC 5322.  That includes the 'Subject: ' text itself
>>> and the '[PATCH ... ]' tags.  So, it is likely that a relatively short
>>> commit subject line gets wrapped.  This increases the length by an
>>> extra line break.  And we're also not taking into account the tags
>>> themselves while checking the length, resulting in false positive
>>> warnings:
>>>
>>>  == Checking "patch.mbox" ==
>>>  WARNING: The subject, '<area>: <summary>', is over 70 characters, i.e., 73.
>>>  Subject: [PATCH] dpif-offload: Add support for offload provider specific
>>>   dp-hash.
>>>  Lines checked: 671, Warnings: 1, Errors: 0
>>>
>>> Fix that by re-joining the split subject and stripping out the tags,
>>> so the subject line length checks are accurate.  This doesn't affect
>>> checking the git commits with -N, since we're formatting the patch
>>> without tags in this case and with an explicit %s that doesn't wrap.
>>>
>>> There is one last issue with this: if the patch file is fed through
>>> stdin, then we're not parsing it as email and only the first line of
>>> the wrapped subject gets checked resulting in false positive 'dot'
>>> warnings and false negative length check results.  Should be fixed
>>> separately.
>>>
>>> Fixes: 1b8fa4a66aa4 ("checkpatch: Add checks for the subject line.")
>>> Signed-off-by: Ilya Maximets <[email protected]>
>>> ---
>> 
>> Thanks for the fix - I have worked around the trigger previously by just
>> applying the patch file and running with the '-X' argument to use git
>> details that strip the mailing list and patch metadata.  But I agree,
>> it's a bit inconvenient.
>> 
>>>  tests/checkpatch.at     | 17 +++++++++++++++++
>>>  utilities/checkpatch.py |  4 ++++
>>>  2 files changed, 21 insertions(+)
>>>
>>> diff --git a/tests/checkpatch.at b/tests/checkpatch.at
>>> index b8fa57ca3..249f0f066 100755
>>> --- a/tests/checkpatch.at
>>> +++ b/tests/checkpatch.at
>>> @@ -665,6 +665,23 @@ try_checkpatch \
>>>      "WARNING: The subject, '<area>: <summary>', is over 70 characters, 
>>> i.e., 85.
>>>      Subject: netdev: This is a way to long commit summary and therefor it 
>>> should report a WARNING!"
>>>  
>>> +try_checkpatch \
>>> +   "Author: A
>>> +    Commit: A
>>> +    Subject: netdev: This is a way to long commit summary and therefor it
>>> +     should report a WARNING!
>>> +
>>> +    Signed-off-by: A" \
>>> +    "WARNING: The subject, '<area>: <summary>', is over 70 characters, 
>>> i.e., 85.
>>> +    Subject: netdev: This is a way to long commit summary and therefor it 
>>> should report a WARNING!"
>>> +
>>> +try_checkpatch \
>>> +   "Author: A
>>> +    Commit: A
>>> +    Subject: [[PATCH v7 branch-x.y RFC]] area: This one is actually not 
>>> that long and should not be reported.
>>> +
>>> +    Signed-off-by: A"
>>> +
>>>  AT_CLEANUP
>>>  
>>>  AT_SETUP([checkpatch - ignore committer as signoff])
>>> diff --git a/utilities/checkpatch.py b/utilities/checkpatch.py
>>> index 387a7bea1..f8f2189d9 100755
>>> --- a/utilities/checkpatch.py
>>> +++ b/utilities/checkpatch.py
>>> @@ -1164,6 +1164,10 @@ def ovs_checkpatch_file(filename):
>>>              print("Subject missing! Your provisional subject is",
>>>                    mail['Subject'])
>>>  
>>> +    subject = ' '.join(mail['Subject'].split())
>>> +    subject = re.sub(r'^\[PATCH[^\]]*\]\s*', '', subject)
>> 
>> Sometimes people have patch files where they set subject prefix to be:
>> 
>>  [RFC PATCH ... ]
>> 
>> or even just
>> 
>>  [RFC .. ]
>> 
>> So I think the expression should be something like:
>> 
>>   r'^\[(PATCH|RFC)[^\]]*\]\s*'
>> 
>> I did a quick test with this expression for the following subjects:
>> 
>>   [PATCH RFC] asdf fdsa
>>   [RFC PATCH] asdf fdsa
>>   [RFC] asdf fdsa
>>   [PATCH] asdf fdsa
>>   [PATCH v123] asdf fdsa
>> 
>> All substituted equally.
> Makes sense.  I can update the regex on commit or send a new version,
> what do you prefer?

On commit is fine.  In that case, add my:

  Reviewed-by: Aaron Conole <[email protected]>

:)

> Best regards, Ilya Maximets.
_______________________________________________
dev mailing list
[email protected]
https://mail.openvswitch.org/mailman/listinfo/ovs-dev

Reply via email to