* [PATCH] checkpatch: Update git commit message
@ 2015-01-09 21:58 Joe Perches
2015-01-10 20:08 ` Chris Rorvick
2015-01-12 13:20 ` Prarit Bhargava
0 siblings, 2 replies; 3+ messages in thread
From: Joe Perches @ 2015-01-09 21:58 UTC (permalink / raw)
To: Andrew Morton; +Cc: Andy Whitcroft, Prarit Bhargava, Daniel Baluta, LKML
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>
---
scripts/checkpatch.pl | 45 ++++++++++++++++++++++++++++++++-------------
1 file changed, 32 insertions(+), 13 deletions(-)
diff --git a/scripts/checkpatch.pl b/scripts/checkpatch.pl
index 6afc24b..5d8c1f1 100755
--- a/scripts/checkpatch.pl
+++ b/scripts/checkpatch.pl
@@ -634,6 +634,8 @@ sub git_commit_info {
$output =~ s/^\s*//gm;
my @lines = split("\n", $output);
+ return ($id, $desc) if ($#lines < 0);
+
if ($lines[0] =~ /^error: short SHA1 $commit is ambiguous\./) {
# Maybe one day convert this block of bash into something that returns
# all matching commit ids, but it's very slow...
@@ -2173,21 +2175,38 @@ sub process {
"Remove Gerrit Change-Id's before submitting upstream.\n" . $herecurr);
}
-# Check for improperly formed commit descriptions
- if ($in_commit_log &&
- $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;
+# Check for git id commit length and improperly formed commit descriptions
+ if ($in_commit_log && $line =~ /\b(c)ommit\s+([0-9a-f]{5,})/i) {
my $init_char = $1;
my $orig_commit = lc($2);
- my $id = '01234567890ab';
- my $desc = 'commit description';
- ($id, $desc) = git_commit_info($orig_commit, $id, $desc);
- ERROR("GIT_COMMIT_ID",
- "Please use 12 or more chars for the git commit ID like: '${init_char}ommit $id (\"$desc\")'\n" . $herecurr);
+ my $short = 1;
+ my $long = 0;
+ my $case = 1;
+ my $space = 1;
+ 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
^ permalink raw reply related [flat|nested] 3+ messages in thread
* Re: [PATCH] checkpatch: Update git commit message
2015-01-09 21:58 [PATCH] checkpatch: Update git commit message Joe Perches
@ 2015-01-10 20:08 ` Chris Rorvick
2015-01-12 13:20 ` Prarit Bhargava
1 sibling, 0 replies; 3+ messages in thread
From: Chris Rorvick @ 2015-01-10 20:08 UTC (permalink / raw)
To: Joe Perches
Cc: Andrew Morton, Andy Whitcroft, Prarit Bhargava, Daniel Baluta, LKML
On Fri, Jan 9, 2015 at 3:58 PM, Joe Perches <joe@perches.com> wrote:
> The git commit message can be confusing,
>
> Try to clarify the message a bit to reduce
> the confusion when emitted.
I just ignored a few GIT_COMMIT_ID errors last night because I was
confused by the message. My mistake was forgetting to quote the commit
summary. Running checkpatch with this makes the problem clear.
Tested-by: Chris Rorvick <chris@rorvick.com>
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [PATCH] checkpatch: Update git commit message
2015-01-09 21:58 [PATCH] checkpatch: Update git commit message Joe Perches
2015-01-10 20:08 ` Chris Rorvick
@ 2015-01-12 13:20 ` Prarit Bhargava
1 sibling, 0 replies; 3+ messages in thread
From: Prarit Bhargava @ 2015-01-12 13:20 UTC (permalink / raw)
To: Joe Perches; +Cc: Andrew Morton, Andy Whitcroft, Daniel Baluta, LKML
On 01/09/2015 04:58 PM, Joe Perches wrote:
> 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>
> ---
Acked-by: Prarit Bhargava <prarit@redhat.com>
P.
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2015-01-12 13:20 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2015-01-09 21:58 [PATCH] checkpatch: Update git commit message Joe Perches
2015-01-10 20:08 ` Chris Rorvick
2015-01-12 13:20 ` Prarit Bhargava
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.