2020-02-13 05:50:40

by John Hubbard

[permalink] [raw]
Subject: [PATCH v2 0/1] checkpatch: support "base-commit:" format

========================================================================
Changes since v1:

* Changed to extend an existing regex line, instead of adding a new line
(suggested by Joe Perches). Adjusted the commit description slightly
to match.

========================================================================

In order to support the get-lore-mbox.py tool described in [1], I ran:

git format-patch --base=<commit> --cover-letter <revrange>

...which generated a "base-commit: <commit-hash>" tag at the end of the
cover letter, just like you can see at the end of this cover letter.
However, checkpatch.pl generated an error upon encounting
"base-commit:" in the cover letter.

So, I suspect that no one is actually using the --base option yet, but
if [1] leads to get-lore-mbox.py and similar scripts becoming popular,
then we'll want checkpatch.pl to work well with them. This tiny patch
does that.

An alternative approach to fixing this would be to make the --base
option emit a checkpatch-friendly commit style. However, I think that's
much less desirable, because base-commit is really just for tools
(mainly "git am") to consume. And so we don't really want it to take up
any more valuable lines in the commit letter than it already does.

thanks,
John Hubbard
NVIDIA

John Hubbard (1):
checkpatch: support "base-commit:" format

scripts/checkpatch.pl | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)


base-commit: 0bf999f9c5e74c7ecf9dafb527146601e5c848b9
--
2.25.0


2020-02-13 05:52:22

by John Hubbard

[permalink] [raw]
Subject: [PATCH v2 1/1] checkpatch: support "base-commit:" format

In order to support the get-lore-mbox.py tool described in [1], I ran:

git format-patch --base=<commit> --cover-letter <revrange>

...which generated a "base-commit: <commit-hash>" tag at the end of the
cover letter. However, checkpatch.pl generated an error upon encounting
"base-commit:" in the cover letter:

"ERROR: Please use git commit description style..."

...because it found the "commit" keyword, and failed to recognize that
it was part of the "base-commit" phrase, and as such, should not be
subjected to the same commit description style rules.

Update checkpatch.pl to include a special case for "base-commit:" (at
the start of the line, possibly with some leading whitespace) so
that that tag no longer generates a checkpatch error.

[1] https://lwn.net/Articles/811528/ "Better tools for kernel
developers"

Cc: Andy Whitcroft <[email protected]>
Suggested-by: Joe Perches <[email protected]>
Cc: Konstantin Ryabitsev <[email protected]>
Cc: Jonathan Corbet <[email protected]>
Signed-off-by: John Hubbard <[email protected]>
---
scripts/checkpatch.pl | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/scripts/checkpatch.pl b/scripts/checkpatch.pl
index a63380c6b0d2..1e66fc7a2f2f 100755
--- a/scripts/checkpatch.pl
+++ b/scripts/checkpatch.pl
@@ -2761,7 +2761,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 !~ /^\s*(?:Link|Patchwork|http|https|BugLink|base-commit):/i &&
$line !~ /^This reverts commit [0-9a-f]{7,40}/ &&
($line =~ /\bcommit\s+[0-9a-f]{5,}\b/i ||
($line =~ /(?:\s|^)[0-9a-f]{12,40}(?:[\s"'\(\[]|$)/i &&
--
2.25.0

2020-02-13 15:47:40

by Joe Perches

[permalink] [raw]
Subject: Re: [PATCH v2 1/1] checkpatch: support "base-commit:" format

On Wed, 2020-02-12 at 21:50 -0800, John Hubbard wrote:
> In order to support the get-lore-mbox.py tool described in [1], I ran:
>
> git format-patch --base=<commit> --cover-letter <revrange>
>
> ...which generated a "base-commit: <commit-hash>" tag at the end of the
> cover letter. However, checkpatch.pl generated an error upon encounting
> "base-commit:" in the cover letter:
>
> "ERROR: Please use git commit description style..."
>
> ...because it found the "commit" keyword, and failed to recognize that
> it was part of the "base-commit" phrase, and as such, should not be
> subjected to the same commit description style rules.
>
> Update checkpatch.pl to include a special case for "base-commit:" (at
> the start of the line, possibly with some leading whitespace) so
> that that tag no longer generates a checkpatch error.
>
> [1] https://lwn.net/Articles/811528/ "Better tools for kernel
> developers"
>
> Cc: Andy Whitcroft <[email protected]>
> Suggested-by: Joe Perches <[email protected]>

Acked-by: Joe Perches <[email protected]>

Andrew, can you pick this up please?

> Cc: Konstantin Ryabitsev <[email protected]>
> Cc: Jonathan Corbet <[email protected]>
> Signed-off-by: John Hubbard <[email protected]>
> ---
> scripts/checkpatch.pl | 2 +-
> 1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/scripts/checkpatch.pl b/scripts/checkpatch.pl
> index a63380c6b0d2..1e66fc7a2f2f 100755
> --- a/scripts/checkpatch.pl
> +++ b/scripts/checkpatch.pl
> @@ -2761,7 +2761,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 !~ /^\s*(?:Link|Patchwork|http|https|BugLink|base-commit):/i &&
> $line !~ /^This reverts commit [0-9a-f]{7,40}/ &&
> ($line =~ /\bcommit\s+[0-9a-f]{5,}\b/i ||
> ($line =~ /(?:\s|^)[0-9a-f]{12,40}(?:[\s"'\(\[]|$)/i &&