diff options
author | Joe Perches <joe@perches.com> | 2016-05-20 20:04:22 -0400 |
---|---|---|
committer | Linus Torvalds <torvalds@linux-foundation.org> | 2016-05-20 20:58:30 -0400 |
commit | 28898fd1a85fa37a59c090271e8be37afe710276 (patch) | |
tree | 35ed8dddbd115756d52bbe59fa44e4f5ab4764ec | |
parent | 0dea9f1eef86bedacad91b6f652ca1ab0d08854c (diff) |
checkpatch: improve --git <commit-count> shortcut
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>
-rwxr-xr-x | scripts/checkpatch.pl | 10 |
1 files changed, 4 insertions, 6 deletions
diff --git a/scripts/checkpatch.pl b/scripts/checkpatch.pl index 928366215fc5..6750595bd7b8 100755 --- a/scripts/checkpatch.pl +++ b/scripts/checkpatch.pl | |||
@@ -809,11 +809,8 @@ if ($git) { | |||
809 | my @commits = (); | 809 | my @commits = (); |
810 | foreach my $commit_expr (@ARGV) { | 810 | foreach my $commit_expr (@ARGV) { |
811 | my $git_range; | 811 | my $git_range; |
812 | if ($commit_expr =~ m/-/) { | 812 | if ($commit_expr =~ m/^(.*)-(\d+)$/) { |
813 | my @tmp = split(/-/, $commit_expr); | 813 | $git_range = "-$2 $1"; |
814 | die "$P: incorrect git commit expression '$commit_expr' $!\n" | ||
815 | if (@tmp != 2); | ||
816 | $git_range = "-$tmp[1] $tmp[0]"; | ||
817 | } elsif ($commit_expr =~ m/\.\./) { | 814 | } elsif ($commit_expr =~ m/\.\./) { |
818 | $git_range = "$commit_expr"; | 815 | $git_range = "$commit_expr"; |
819 | } else { | 816 | } else { |
@@ -821,7 +818,8 @@ if ($git) { | |||
821 | } | 818 | } |
822 | my $lines = `git log --no-color --no-merges --pretty=format:'%H %s' $git_range`; | 819 | my $lines = `git log --no-color --no-merges --pretty=format:'%H %s' $git_range`; |
823 | foreach my $line (split(/\n/, $lines)) { | 820 | foreach my $line (split(/\n/, $lines)) { |
824 | $line =~ /(^\w+) (.*)/; | 821 | $line =~ /^([0-9a-fA-F]{40,40}) (.*)$/; |
822 | next if (!defined($1) || !defined($2)); | ||
825 | my $sha1 = $1; | 823 | my $sha1 = $1; |
826 | my $subject = $2; | 824 | my $subject = $2; |
827 | unshift(@commits, $sha1); | 825 | unshift(@commits, $sha1); |