lkml.org 
[lkml]   [2016]   [May]   [8]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
Patch in this message
/
From
Subject[PATCH 2/2] checkpatch: Improve --git <commit-count> shortcut
Date
The --git <commit-count> shortcut can be confused by a tag with a dash
like v4.4-rc1.

Improve the test to verify the <commit-count> expression ends with a
dash followed by a numeric value.

Improve the git log result to verify the "<sha1> <subject>" output
as well.

Signed-off-by: Joe Perches <joe@perches.com>
---
scripts/checkpatch.pl | 10 ++++------
1 file changed, 4 insertions(+), 6 deletions(-)

diff --git a/scripts/checkpatch.pl b/scripts/checkpatch.pl
index 9283662..6750595 100755
--- a/scripts/checkpatch.pl
+++ b/scripts/checkpatch.pl
@@ -809,11 +809,8 @@ if ($git) {
my @commits = ();
foreach my $commit_expr (@ARGV) {
my $git_range;
- if ($commit_expr =~ m/-/) {
- my @tmp = split(/-/, $commit_expr);
- die "$P: incorrect git commit expression '$commit_expr' $!\n"
- if (@tmp != 2);
- $git_range = "-$tmp[1] $tmp[0]";
+ if ($commit_expr =~ m/^(.*)-(\d+)$/) {
+ $git_range = "-$2 $1";
} elsif ($commit_expr =~ m/\.\./) {
$git_range = "$commit_expr";
} else {
@@ -821,7 +818,8 @@ if ($git) {
}
my $lines = `git log --no-color --no-merges --pretty=format:'%H %s' $git_range`;
foreach my $line (split(/\n/, $lines)) {
- $line =~ /(^\w+) (.*)/;
+ $line =~ /^([0-9a-fA-F]{40,40}) (.*)$/;
+ next if (!defined($1) || !defined($2));
my $sha1 = $1;
my $subject = $2;
unshift(@commits, $sha1);
--
2.8.0.rc4.16.g56331f8
\
 
 \ /
  Last update: 2016-05-08 15:21    [W:0.018 / U:0.672 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site