Skip to contentSkip to conversation

checkpatch: Tolerate upstream commit references

PATCH Superseded Petr Machata 2 participants 3 messages Jun 10, 2025 – Jun 11, 2025 Checkpatch

v2 of 5 Superseded Latest is v5 →

lore
Share & tools
lore
#0 lore raw

PATCH v2 1/1 checkpatch: Tolerate upstream commit references

Two forms of upstream commit references are used (and documented) for stable kernels:

- [ Upstream commit <sha1> ]
- commit <sha1> upstream.

Extend checkpatch so that it doesn't cite these. This reduces noise that downstream maintainers experience when checkpatching patches that may contain commit references of this sort.

---

Notes:
v2:
- No changes, just a ping.

 scripts/checkpatch.pl | 2 ++
 1 file changed, 2 insertions(+)
scripts/checkpatch.pl +2 -0
index 664f7b7a622c..bd4405b59103 100755
@@ -3351,6 +3351,8 @@ sub process {
 		if ($perl_version_ok &&
 		    $in_commit_log && !$commit_log_possible_stack_dump &&
 		    $line !~ /^\s*(?:Link|Patchwork|http|https|BugLink|base-commit):/i &&
+		    $line !~ /^\s*\[ Upstream commit [0-9a-f]{40} ]/ &&
+		    $line !~ /^\s*commit [0-9a-f]{40}\s*upstream\./ &&
 		    $line !~ /^This reverts commit [0-9a-f]{7,40}/ &&
 		    (($line =~ /\bcommit\s+[0-9a-f]{5,}\b/i ||
 		      ($line =~ /\bcommit\s*$/i && defined($rawlines[$linenr]) && $rawlines[$linenr] =~ /^\s*[0-9a-f]{5,}\b/i)) ||
Signature · 1 line
2.49.0
maintainer
#1 lore raw
Quoted 5 lines · Petr Machata

Two forms of upstream commit references are used (and documented) for stable kernels:

- [ Upstream commit <sha1> ]
- commit <sha1> upstream.

Is the sha1 never abbreviated?

scripts/checkpatch.pl

Quoted 1 line
scripts/checkpatch.pl +0 -0

[]

scripts/checkpatch.pl sub process { · line 3355

Quoted 6 lines
scripts/checkpatch.pl +2 -0
@@ -3351,6 +3351,8 @@ sub process {
 		if ($perl_version_ok &&
 		    $in_commit_log && !$commit_log_possible_stack_dump &&
 		    $line !~ /^\s*(?:Link|Patchwork|http|https|BugLink|base-commit):/i &&
+		    $line !~ /^\s*\[ Upstream commit [0-9a-f]{40} ]/ &&
+		    $line !~ /^\s*commit [0-9a-f]{40}\s*upstream\./ &&

always 40 chars?

scripts/checkpatch.pl sub process { · line 3358

Quoted 3 lines
scripts/checkpatch.pl +0 -0
 		    $line !~ /^This reverts commit [0-9a-f]{7,40}/ &&
 		    (($line =~ /\bcommit\s+[0-9a-f]{5,}\b/i ||
 		      ($line =~ /\bcommit\s*$/i && defined($rawlines[$linenr]) && $rawlines[$linenr] =~ /^\s*[0-9a-f]{5,}\b/i)) ||

In stable I see a few like:

commit fef912bf860e upstream.
commit 98af4d4df889 upstream.

and

[ commit d3bd7413e0ca40b60cf60d4003246d067cafdeda upstream ] [ commit 979d63d50c0c0f7bc537bf821e056cc9fe5abd38 upstream ]

and some with an upper case Commit

Commit d6951f582cc50ba0ad22ef46b599740966599b14 upstream.

#2 lore raw
Quoted 8 lines · Joe Perches
Quoted 5 lines · Petr Machata

Two forms of upstream commit references are used (and documented) for stable kernels:

- [ Upstream commit <sha1> ]
- commit <sha1> upstream.

Is the sha1 never abbreviated?

I mean, as per the spec it isn't. I want to make sure I don't let false negatives in, that's the motivation for just going purely by the spec.

Quoted 11 lines

scripts/checkpatch.pl

Quoted 1 line
scripts/checkpatch.pl +0 -0

[]

scripts/checkpatch.pl sub process { · line 3355

Quoted 6 lines
scripts/checkpatch.pl +2 -0
@@ -3351,6 +3351,8 @@ sub process {
 		if ($perl_version_ok &&
 		    $in_commit_log && !$commit_log_possible_stack_dump &&
 		    $line !~ /^\s*(?:Link|Patchwork|http|https|BugLink|base-commit):/i &&
+		    $line !~ /^\s*\[ Upstream commit [0-9a-f]{40} ]/ &&
+		    $line !~ /^\s*commit [0-9a-f]{40}\s*upstream\./ &&

always 40 chars?

Quoted 8 lines

scripts/checkpatch.pl sub process { · line 3358

Quoted 3 lines
scripts/checkpatch.pl +0 -0
 		    $line !~ /^This reverts commit [0-9a-f]{7,40}/ &&
 		    (($line =~ /\bcommit\s+[0-9a-f]{5,}\b/i ||
 		      ($line =~ /\bcommit\s*$/i && defined($rawlines[$linenr]) && $rawlines[$linenr] =~ /^\s*[0-9a-f]{5,}\b/i)) ||

In stable I see a few like:

commit fef912bf860e upstream.
commit 98af4d4df889 upstream.

There are a couple hits, but most come from 2018, one from 2021 and one from 2022. My intuition is to ignore these because of the combination of how old and how rare they are, but maybe it's better to assume a slip like this will come up at some point again.

Quoted 5 lines

and

[ commit d3bd7413e0ca40b60cf60d4003246d067cafdeda upstream ] [ commit 979d63d50c0c0f7bc537bf821e056cc9fe5abd38 upstream ]

Yeah, there's a bunch of these in 2019.

Quoted 3 lines

and some with an upper case Commit

Commit d6951f582cc50ba0ad22ef46b599740966599b14 upstream.

OK, this one seems to be used on occasion. Even see hits from this year. I think it might make sense to support this as well. Hmm, and then this in brackets seems to be used a bunch, too.

So maybe I should generalize it a bit and ignore the hash check if either of these hits?

(\[ )?[Uu]pstream commit [0-9a-f]{12,40}\.?( ])?
(\[ )?[Cc]ommit [0-9a-f]{12,40} upstream\.?( ])?