Skip to content

Commit 948b133

Browse files
xyprontorvalds
authored andcommitted
checkpatch: remove false warning for commit reference
Checkpatch warns of an incorrect commit reference style for any hexadecimal number of 12 digits and more. Numbers of 12 digits are not necessarily commit ids. For an example provoking the problem see https://patchwork.kernel.org/patch/9170897/ Checkpatch should only warn if the number refers to an existing commit. Link: http://lkml.kernel.org/r/[email protected] Signed-off-by: Heinrich Schuchardt <[email protected]> Acked-by: Joe Perches <[email protected]> Signed-off-by: Andrew Morton <[email protected]> Signed-off-by: Linus Torvalds <[email protected]>
1 parent ca81986 commit 948b133

File tree

1 file changed

+3
-1
lines changed

1 file changed

+3
-1
lines changed

scripts/checkpatch.pl

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -867,6 +867,7 @@ sub git_commit_info {
867867
# echo "commit $(cut -c 1-12,41-)"
868868
# done
869869
} elsif ($lines[0] =~ /^fatal: ambiguous argument '$commit': unknown revision or path not in the working tree\./) {
870+
$id = undef;
870871
} else {
871872
$id = substr($lines[0], 0, 12);
872873
$desc = substr($lines[0], 41);
@@ -2606,7 +2607,8 @@ sub process {
26062607
($id, $description) = git_commit_info($orig_commit,
26072608
$id, $orig_desc);
26082609

2609-
if ($short || $long || $space || $case || ($orig_desc ne $description) || !$hasparens) {
2610+
if (defined($id) &&
2611+
($short || $long || $space || $case || ($orig_desc ne $description) || !$hasparens)) {
26102612
ERROR("GIT_COMMIT_ID",
26112613
"Please use git commit description style 'commit <12+ chars of sha1> (\"<title line>\")' - ie: '${init_char}ommit $id (\"$description\")'\n" . $herecurr);
26122614
}

0 commit comments

Comments
 (0)