]> git.baikalelectronics.ru Git - kernel.git/commitdiff
checkpatch: improve --git <commit-count> shortcut
authorJoe Perches <joe@perches.com>
Sat, 21 May 2016 00:04:22 +0000 (17:04 -0700)
committerLinus Torvalds <torvalds@linux-foundation.org>
Sat, 21 May 2016 00:58:30 +0000 (17:58 -0700)
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.

Link: http://lkml.kernel.org/r/c4a3f759291d967641860c3a54bb81177f34325f.1462711962.git.joe@perches.com
Signed-off-by: Joe Perches <joe@perches.com>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
scripts/checkpatch.pl

index 928366215fc53877df21b35d375b10838c219f0a..6750595bd7b819883b5b4ae8dde3fdfacf0f37fb 100755 (executable)
@@ -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);