aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJoe Perches <joe@perches.com>2016-05-20 20:04:19 -0400
committerLinus Torvalds <torvalds@linux-foundation.org>2016-05-20 20:58:30 -0400
commit0dea9f1eef86bedacad91b6f652ca1ab0d08854c (patch)
tree7ba86ac1944e34baa4647f5b44cae3aab87e0d8a
parent4a593c3448312906358b00898c29a95278d82cc9 (diff)
checkpatch: reduce number of `git log` calls with --git
checkpatch currently calls git log multiple times to first get the <revision range> sha1 values and again to get the subject for each individual sha1 commit. Always get the sha1 and subject at the same time instead. Store the subject in a sha1 hash to avoid the second git log exec. Link: http://lkml.kernel.org/r/274efab2332ad2308ab5de85a95d255f6e2de5f3.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-xscripts/checkpatch.pl23
1 files changed, 13 insertions, 10 deletions
diff --git a/scripts/checkpatch.pl b/scripts/checkpatch.pl
index 8fc9edd3289a..928366215fc5 100755
--- a/scripts/checkpatch.pl
+++ b/scripts/checkpatch.pl
@@ -28,6 +28,7 @@ my $terse = 0;
28my $showfile = 0; 28my $showfile = 0;
29my $file = 0; 29my $file = 0;
30my $git = 0; 30my $git = 0;
31my %git_commits = ();
31my $check = 0; 32my $check = 0;
32my $check_orig = 0; 33my $check_orig = 0;
33my $summary = 1; 34my $summary = 1;
@@ -806,23 +807,25 @@ die "$P: No git repository found\n" if ($git && !-e ".git");
806 807
807if ($git) { 808if ($git) {
808 my @commits = (); 809 my @commits = ();
809 for my $commit_expr (@ARGV) { 810 foreach my $commit_expr (@ARGV) {
810 my $git_range; 811 my $git_range;
811 if ($commit_expr =~ m/-/) { 812 if ($commit_expr =~ m/-/) {
812 my @tmp = split(/-/, $commit_expr); 813 my @tmp = split(/-/, $commit_expr);
813 die "$P: incorrect git commits expression $commit_expr$!\n" 814 die "$P: incorrect git commit expression '$commit_expr' $!\n"
814 if (@tmp != 2); 815 if (@tmp != 2);
815 $git_range = "-$tmp[1] $tmp[0]"; 816 $git_range = "-$tmp[1] $tmp[0]";
816 } elsif ($commit_expr =~ m/\.\./) { 817 } elsif ($commit_expr =~ m/\.\./) {
817 $git_range = "$commit_expr"; 818 $git_range = "$commit_expr";
818 }
819 if (defined $git_range) {
820 my $lines = `git log --no-merges --pretty=format:'%H' $git_range`;
821 foreach my $line (split(/\n/, $lines)) {
822 unshift(@commits, $line);
823 }
824 } else { 819 } else {
825 unshift(@commits, $commit_expr); 820 $git_range = "-1 $commit_expr";
821 }
822 my $lines = `git log --no-color --no-merges --pretty=format:'%H %s' $git_range`;
823 foreach my $line (split(/\n/, $lines)) {
824 $line =~ /(^\w+) (.*)/;
825 my $sha1 = $1;
826 my $subject = $2;
827 unshift(@commits, $sha1);
828 $git_commits{$sha1} = $subject;
826 } 829 }
827 } 830 }
828 die "$P: no git commits after extraction!\n" if (@commits == 0); 831 die "$P: no git commits after extraction!\n" if (@commits == 0);
@@ -847,7 +850,7 @@ for my $filename (@ARGV) {
847 if ($filename eq '-') { 850 if ($filename eq '-') {
848 $vname = 'Your patch'; 851 $vname = 'Your patch';
849 } elsif ($git) { 852 } elsif ($git) {
850 $vname = "Commit " . substr($filename, 0, 12) . `git log -1 --pretty=format:' ("%s")' $filename`; 853 $vname = "Commit " . substr($filename, 0, 12) . ' ("' . $git_commits{$filename} . '")';
851 } else { 854 } else {
852 $vname = $filename; 855 $vname = $filename;
853 } 856 }