2017-04-11 17:42:58

by Wei Wang

[permalink] [raw]
Subject: [PATCH] checkpatch: special audit for revert commit line

From: Wei Wang <[email protected]>

Currently checkpatch.pl does not recognize revert commits and
complains about the commit hash format.
Add special audit for revert commit to fix it.

Signed-off-by: Wei Wang <[email protected]>
---
scripts/checkpatch.pl | 1 +
1 file changed, 1 insertion(+)

diff --git a/scripts/checkpatch.pl b/scripts/checkpatch.pl
index baa3c7be04ad..60c3b9e6a46b 100755
--- a/scripts/checkpatch.pl
+++ b/scripts/checkpatch.pl
@@ -2539,6 +2539,7 @@ sub process {
# Check for git id commit length and improperly formed commit descriptions
if ($in_commit_log && !$commit_log_possible_stack_dump &&
$line !~ /^\s*(?:Link|Patchwork|http|https|BugLink):/i &&
+ $line !~ /^This reverts commit [0-9a-f]{12,40}\./ &&
($line =~ /\bcommit\s+[0-9a-f]{5,}\b/i ||
($line =~ /(?:\s|^)[0-9a-f]{12,40}(?:[\s"'\(\[]|$)/i &&
$line !~ /[\<\[][0-9a-f]{12,40}[\>\]]/i &&
--
2.12.2.715.g7642488e1d-goog


2017-04-11 18:39:11

by Joe Perches

[permalink] [raw]
Subject: Re: [PATCH] checkpatch: special audit for revert commit line

On Tue, 2017-04-11 at 10:41 -0700, Wei Wang wrote:
> From: Wei Wang <[email protected]>
>
> Currently checkpatch.pl does not recognize revert commits and
> complains about the commit hash format.
> Add special audit for revert commit to fix it.

The commit wording seems a bit off, but I guess it's OK.

The 'This reverts commit <sha1>.' is git's default
commit revert message.

There are many uses that contain additional content
after the sha1 in git log so perhaps using

$line !~ /^This reverts commit [0-9a-f]{7,40}/

is more robust/better.

$ git log --format=email --grep=revert -i -100000 | \
grep "This reverts commit" | \
sed -r 's/This reverts commit [0-9a-f]{12,40}\.?//' | \
sort | uniq
<a longish list of modified git revert commit messages>

> Signed-off-by: Wei Wang <[email protected]>
> ---
> scripts/checkpatch.pl | 1 +
> 1 file changed, 1 insertion(+)
>
> diff --git a/scripts/checkpatch.pl b/scripts/checkpatch.pl
> index baa3c7be04ad..60c3b9e6a46b 100755
> --- a/scripts/checkpatch.pl
> +++ b/scripts/checkpatch.pl
> @@ -2539,6 +2539,7 @@ sub process {
> # Check for git id commit length and improperly formed commit descriptions
> if ($in_commit_log && !$commit_log_possible_stack_dump &&
> $line !~ /^\s*(?:Link|Patchwork|http|https|BugLink):/i &&
> + $line !~ /^This reverts commit [0-9a-f]{12,40}\./ &&
> ($line =~ /\bcommit\s+[0-9a-f]{5,}\b/i ||
> ($line =~ /(?:\s|^)[0-9a-f]{12,40}(?:[\s"'\(\[]|$)/i &&
> $line !~ /[\<\[][0-9a-f]{12,40}[\>\]]/i &&