aboutsummaryrefslogtreecommitdiffstats
path: root/scripts
diff options
context:
space:
mode:
authorJoe Perches <joe@perches.com>2015-02-13 17:38:35 -0500
committerLinus Torvalds <torvalds@linux-foundation.org>2015-02-14 00:21:39 -0500
commit0d7835fcaa67bb21e5ffd50afaa65c81c53f8856 (patch)
treeb4a4a6388a98525e24fa9ad12b2b3d8a00ce9fd9 /scripts
parent1b36b201c081ddb6ced1983c5ebf75fa635b6e4b (diff)
checkpatch: update git commit message
The git commit message can be confusing, Try to clarify the message a bit to reduce the confusion when emitted. Show the correct form using Please use git commit description style 'commit <12+ chars of sha1> ("<title line>")' and if the git commit sha1 is unique, show the right sha1 to use with the actual title Signed-off-by: Joe Perches <joe@perches.com> Original-patch-by: Prarit Bhargava <prarit@redhat.com> Tested-by: Chris Rorvick <chris@rorvick.com> Acked-by: Prarit Bhargava <prarit@redhat.com> Cc: Daniel Baluta <daniel.baluta@intel.com> Signed-off-by: Andrew Morton <akpm@linux-foundation.org> Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Diffstat (limited to 'scripts')
-rwxr-xr-xscripts/checkpatch.pl45
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