Commit 0d7835fc authored by Joe Perches's avatar Joe Perches Committed by Linus Torvalds

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: default avatarJoe Perches <joe@perches.com>
Original-patch-by: default avatarPrarit Bhargava <prarit@redhat.com>
Tested-by: default avatarChris Rorvick <chris@rorvick.com>
Acked-by: default avatarPrarit Bhargava <prarit@redhat.com>
Cc: Daniel Baluta <daniel.baluta@intel.com>
Signed-off-by: default avatarAndrew Morton <akpm@linux-foundation.org>
Signed-off-by: default avatarLinus Torvalds <torvalds@linux-foundation.org>
parent 1b36b201
...@@ -634,6 +634,8 @@ sub git_commit_info { ...@@ -634,6 +634,8 @@ sub git_commit_info {
$output =~ s/^\s*//gm; $output =~ s/^\s*//gm;
my @lines = split("\n", $output); my @lines = split("\n", $output);
return ($id, $desc) if ($#lines < 0);
if ($lines[0] =~ /^error: short SHA1 $commit is ambiguous\./) { if ($lines[0] =~ /^error: short SHA1 $commit is ambiguous\./) {
# Maybe one day convert this block of bash into something that returns # Maybe one day convert this block of bash into something that returns
# all matching commit ids, but it's very slow... # all matching commit ids, but it's very slow...
...@@ -2173,21 +2175,38 @@ sub process { ...@@ -2173,21 +2175,38 @@ sub process {
"Remove Gerrit Change-Id's before submitting upstream.\n" . $herecurr); "Remove Gerrit Change-Id's before submitting upstream.\n" . $herecurr);
} }
# Check for improperly formed commit descriptions # Check for git id commit length and improperly formed commit descriptions
if ($in_commit_log && if ($in_commit_log && $line =~ /\b(c)ommit\s+([0-9a-f]{5,})/i) {
$line =~ /\bcommit\s+[0-9a-f]{5,}/i &&
!($line =~ /\b[Cc]ommit [0-9a-f]{12,40} \("/ ||
($line =~ /\b[Cc]ommit [0-9a-f]{12,40}\s*$/ &&
defined $rawlines[$linenr] &&
$rawlines[$linenr] =~ /^\s*\("/))) {
$line =~ /\b(c)ommit\s+([0-9a-f]{5,})/i;
my $init_char = $1; my $init_char = $1;
my $orig_commit = lc($2); my $orig_commit = lc($2);
my $id = '01234567890ab'; my $short = 1;
my $desc = 'commit description'; my $long = 0;
($id, $desc) = git_commit_info($orig_commit, $id, $desc); my $case = 1;
ERROR("GIT_COMMIT_ID", my $space = 1;
"Please use 12 or more chars for the git commit ID like: '${init_char}ommit $id (\"$desc\")'\n" . $herecurr); my $hasdesc = 0;
my $id = '0123456789ab';
my $orig_desc = "commit description";
my $description = "";
$short = 0 if ($line =~ /\bcommit\s+[0-9a-f]{12,40}/i);
$long = 1 if ($line =~ /\bcommit\s+[0-9a-f]{41,}/i);
$space = 0 if ($line =~ /\bcommit [0-9a-f]/i);
$case = 0 if ($line =~ /\b[Cc]ommit\s+[0-9a-f]{5,40}[^A-F]/);
if ($line =~ /\bcommit\s+[0-9a-f]{5,}\s+\("([^"]+)"\)/i) {
$orig_desc = $1;
} elsif ($line =~ /\bcommit\s+[0-9a-f]{5,}\s*$/i &&
defined $rawlines[$linenr] &&
$rawlines[$linenr] =~ /^\s*\("([^"]+)"\)/) {
$orig_desc = $1;
}
($id, $description) = git_commit_info($orig_commit,
$id, $orig_desc);
if ($short || $long || $space || $case || ($orig_desc ne $description)) {
ERROR("GIT_COMMIT_ID",
"Please use git commit description style 'commit <12+ chars of sha1> (\"<title line>\")' - ie: '${init_char}ommit $id (\"$description\")'\n" . $herecurr);
}
} }
# Check for added, moved or deleted files # Check for added, moved or deleted files
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment