diff options
Diffstat (limited to 'scripts')
| -rwxr-xr-x | scripts/checkpatch.pl | 45 |
1 files changed, 32 insertions, 13 deletions
diff --git a/scripts/checkpatch.pl b/scripts/checkpatch.pl index 6ac355edd0dc..786017d4d057 100755 --- a/scripts/checkpatch.pl +++ b/scripts/checkpatch.pl | |||
| @@ -634,6 +634,8 @@ sub git_commit_info { | |||
| 634 | $output =~ s/^\s*//gm; | 634 | $output =~ s/^\s*//gm; |
| 635 | my @lines = split("\n", $output); | 635 | my @lines = split("\n", $output); |
| 636 | 636 | ||
| 637 | return ($id, $desc) if ($#lines < 0); | ||
| 638 | |||
| 637 | if ($lines[0] =~ /^error: short SHA1 $commit is ambiguous\./) { | 639 | if ($lines[0] =~ /^error: short SHA1 $commit is ambiguous\./) { |
| 638 | # Maybe one day convert this block of bash into something that returns | 640 | # Maybe one day convert this block of bash into something that returns |
| 639 | # all matching commit ids, but it's very slow... | 641 | # all matching commit ids, but it's very slow... |
| @@ -2173,21 +2175,38 @@ sub process { | |||
| 2173 | "Remove Gerrit Change-Id's before submitting upstream.\n" . $herecurr); | 2175 | "Remove Gerrit Change-Id's before submitting upstream.\n" . $herecurr); |
| 2174 | } | 2176 | } |
| 2175 | 2177 | ||
| 2176 | # Check for improperly formed commit descriptions | 2178 | # Check for git id commit length and improperly formed commit descriptions |
| 2177 | if ($in_commit_log && | 2179 | if ($in_commit_log && $line =~ /\b(c)ommit\s+([0-9a-f]{5,})/i) { |
| 2178 | $line =~ /\bcommit\s+[0-9a-f]{5,}/i && | ||
| 2179 | !($line =~ /\b[Cc]ommit [0-9a-f]{12,40} \("/ || | ||
| 2180 | ($line =~ /\b[Cc]ommit [0-9a-f]{12,40}\s*$/ && | ||
| 2181 | defined $rawlines[$linenr] && | ||
| 2182 | $rawlines[$linenr] =~ /^\s*\("/))) { | ||
| 2183 | $line =~ /\b(c)ommit\s+([0-9a-f]{5,})/i; | ||
| 2184 | my $init_char = $1; | 2180 | my $init_char = $1; |
| 2185 | my $orig_commit = lc($2); | 2181 | my $orig_commit = lc($2); |
| 2186 | my $id = '01234567890ab'; | 2182 | my $short = 1; |
| 2187 | my $desc = 'commit description'; | 2183 | my $long = 0; |
| 2188 | ($id, $desc) = git_commit_info($orig_commit, $id, $desc); | 2184 | my $case = 1; |
| 2189 | ERROR("GIT_COMMIT_ID", | 2185 | my $space = 1; |
| 2190 | "Please use 12 or more chars for the git commit ID like: '${init_char}ommit $id (\"$desc\")'\n" . $herecurr); | 2186 | my $hasdesc = 0; |
| 2187 | my $id = '0123456789ab'; | ||
| 2188 | my $orig_desc = "commit description"; | ||
| 2189 | my $description = ""; | ||
| 2190 | |||
| 2191 | $short = 0 if ($line =~ /\bcommit\s+[0-9a-f]{12,40}/i); | ||
| 2192 | $long = 1 if ($line =~ /\bcommit\s+[0-9a-f]{41,}/i); | ||
| 2193 | $space = 0 if ($line =~ /\bcommit [0-9a-f]/i); | ||
| 2194 | $case = 0 if ($line =~ /\b[Cc]ommit\s+[0-9a-f]{5,40}[^A-F]/); | ||
| 2195 | if ($line =~ /\bcommit\s+[0-9a-f]{5,}\s+\("([^"]+)"\)/i) { | ||
| 2196 | $orig_desc = $1; | ||
| 2197 | } elsif ($line =~ /\bcommit\s+[0-9a-f]{5,}\s*$/i && | ||
| 2198 | defined $rawlines[$linenr] && | ||
| 2199 | $rawlines[$linenr] =~ /^\s*\("([^"]+)"\)/) { | ||
| 2200 | $orig_desc = $1; | ||
| 2201 | } | ||
| 2202 | |||
| 2203 | ($id, $description) = git_commit_info($orig_commit, | ||
| 2204 | $id, $orig_desc); | ||
| 2205 | |||
| 2206 | if ($short || $long || $space || $case || ($orig_desc ne $description)) { | ||
| 2207 | ERROR("GIT_COMMIT_ID", | ||
| 2208 | "Please use git commit description style 'commit <12+ chars of sha1> (\"<title line>\")' - ie: '${init_char}ommit $id (\"$description\")'\n" . $herecurr); | ||
| 2209 | } | ||
| 2191 | } | 2210 | } |
| 2192 | 2211 | ||
| 2193 | # Check for added, moved or deleted files | 2212 | # Check for added, moved or deleted files |
