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.
Showing the changes to scripts/checkpatch.pl (1 of 1 file). Show all
Unified · Split
| @@ -809,11 +809,8 @@ if ($git) { · 808 unmodified lines | ||
| 809 | 809 | my @commits = (); |
| 810 | 810 | foreach my $commit_expr (@ARGV) { |
| 811 | 811 | my $git_range; |
| 812 | − if ($commit_expr =~ m/-/) { | |
| 813 | − my @tmp = split(/-/, $commit_expr); | |
| 814 | − die "$P: incorrect git commit expression '$commit_expr' $!\n" | |
| 815 | − if (@tmp != 2); | |
| 816 | − $git_range = "-$tmp[1] $tmp[0]"; | |
| 812 | + if ($commit_expr =~ m/^(.*)-(\d+)$/) { | |
| 813 | + $git_range = "-$2 $1"; | |
| 817 | 814 | } elsif ($commit_expr =~ m/\.\./) { |
| 818 | 815 | $git_range = "$commit_expr"; |
| 819 | 816 | } else { |
| @@ -821,7 +818,8 @@ if ($git) { · 1 unmodified line | ||
| 821 | 818 | } |
| 822 | 819 | my $lines = `git log --no-color --no-merges --pretty=format:'%H %s' $git_range`; |
| 823 | 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 | 823 | my $sha1 = $1; |
| 826 | 824 | my $subject = $2; |
| 827 | 825 | unshift(@commits, $sha1); |