aboutsummaryrefslogtreecommitdiffstats
path: root/scripts
diff options
context:
space:
mode:
authorJoe Perches <joe@perches.com>2009-12-14 21:00:49 -0500
committerLinus Torvalds <torvalds@linux-foundation.org>2009-12-15 11:53:28 -0500
commita8af2430f3fb997951eff3d0d51cb166b399782b (patch)
treee7a82410bd26354ee5888ed54de563d514f85f51 /scripts
parent3c7385b81f721f0e7648d5134afb2088b28f8c69 (diff)
scripts/get_maintainer.pl: fix --non with --git-blame and cleanups
Fix email matching without name --n and --git-blame Using --non and --git-blame caused maintainer signature matching to fail. Fixed that by adding 3rd argument to sub format_email to control show/hide name portion of address Slurp -f file instead of reading line-by-line for K: pattern matching. Suggested by Wolfram Sang as more efficient Refactor git command execution Break into 2 functions, execute/analyze Share code between --git and --git-blame Don't warn multiple times when git isn't installed Improve stats reporting --git-min-percent and -- rolestats now count the total number of commits for either the period of --git-since or if using --git-blame the commits used by the current file and calculate commit % as # of commits signed / total commits * 100 Code style cleaning Use consistent sub foo { my (args...) = @_; Signed-off-by: Joe Perches <joe@perches.com> Cc: Ben Hutchings <ben@decadent.org.uk> Cc: Greg KH <greg@kroah.com> Cc: Pavel Machek <pavel@ucw.cz> Cc: Wolfram Sang <w.sang@pengutronix.de> Signed-off-by: Andrew Morton <akpm@linux-foundation.org> Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Diffstat (limited to 'scripts')
-rwxr-xr-xscripts/get_maintainer.pl198
1 files changed, 104 insertions, 94 deletions
diff --git a/scripts/get_maintainer.pl b/scripts/get_maintainer.pl
index 4e11c271e613..fe91a984247b 100755
--- a/scripts/get_maintainer.pl
+++ b/scripts/get_maintainer.pl
@@ -182,7 +182,7 @@ if ($email_remove_duplicates) {
182 next if ($line =~ m/^\s*$/); 182 next if ($line =~ m/^\s*$/);
183 183
184 my ($name, $address) = parse_email($line); 184 my ($name, $address) = parse_email($line);
185 $line = format_email($name, $address); 185 $line = format_email($name, $address, $email_usename);
186 186
187 next if ($line =~ m/^\s*$/); 187 next if ($line =~ m/^\s*$/);
188 188
@@ -214,12 +214,10 @@ foreach my $file (@ARGV) {
214 push(@files, $file); 214 push(@files, $file);
215 if (-f $file && $keywords) { 215 if (-f $file && $keywords) {
216 open(FILE, "<$file") or die "$P: Can't open ${file}\n"; 216 open(FILE, "<$file") or die "$P: Can't open ${file}\n";
217 while (<FILE>) { 217 my $text = do { local($/) ; <FILE> };
218 my $patch_line = $_; 218 foreach my $line (keys %keyword_hash) {
219 foreach my $line (keys %keyword_hash) { 219 if ($text =~ m/$keyword_hash{$line}/x) {
220 if ($patch_line =~ m/^.*$keyword_hash{$line}/x) { 220 push(@keyword_tvi, $line);
221 push(@keyword_tvi, $line);
222 }
223 } 221 }
224 } 222 }
225 close(FILE); 223 close(FILE);
@@ -311,7 +309,7 @@ foreach my $file (@files) {
311 } 309 }
312 310
313 if ($email && $email_git) { 311 if ($email && $email_git) {
314 recent_git_signoffs($file); 312 git_file_signoffs($file);
315 } 313 }
316 314
317 if ($email && $email_git_blame) { 315 if ($email && $email_git_blame) {
@@ -331,7 +329,7 @@ if ($email) {
331 if ($chief =~ m/^(.*):(.*)/) { 329 if ($chief =~ m/^(.*):(.*)/) {
332 my $email_address; 330 my $email_address;
333 331
334 $email_address = format_email($1, $2); 332 $email_address = format_email($1, $2, $email_usename);
335 if ($email_git_penguin_chiefs) { 333 if ($email_git_penguin_chiefs) {
336 push(@email_to, [$email_address, 'chief penguin']); 334 push(@email_to, [$email_address, 'chief penguin']);
337 } else { 335 } else {
@@ -509,7 +507,7 @@ sub parse_email {
509} 507}
510 508
511sub format_email { 509sub format_email {
512 my ($name, $address) = @_; 510 my ($name, $address, $usename) = @_;
513 511
514 my $formatted_email; 512 my $formatted_email;
515 513
@@ -522,11 +520,11 @@ sub format_email {
522 $name = "\"$name\""; 520 $name = "\"$name\"";
523 } 521 }
524 522
525 if ($email_usename) { 523 if ($usename) {
526 if ("$name" eq "") { 524 if ("$name" eq "") {
527 $formatted_email = "$address"; 525 $formatted_email = "$address";
528 } else { 526 } else {
529 $formatted_email = "$name <${address}>"; 527 $formatted_email = "$name <$address>";
530 } 528 }
531 } else { 529 } else {
532 $formatted_email = $address; 530 $formatted_email = $address;
@@ -671,7 +669,7 @@ sub add_categories {
671 if ($tv =~ m/^(\C):\s*(.*)/) { 669 if ($tv =~ m/^(\C):\s*(.*)/) {
672 if ($1 eq "P") { 670 if ($1 eq "P") {
673 $name = $2; 671 $name = $2;
674 $pvalue = format_email($name, $address); 672 $pvalue = format_email($name, $address, $email_usename);
675 } 673 }
676 } 674 }
677 } 675 }
@@ -714,9 +712,9 @@ sub push_email_address {
714 } 712 }
715 713
716 if (!$email_remove_duplicates) { 714 if (!$email_remove_duplicates) {
717 push(@email_to, [format_email($name, $address), $role]); 715 push(@email_to, [format_email($name, $address, $email_usename), $role]);
718 } elsif (!email_inuse($name, $address)) { 716 } elsif (!email_inuse($name, $address)) {
719 push(@email_to, [format_email($name, $address), $role]); 717 push(@email_to, [format_email($name, $address, $email_usename), $role]);
720 $email_hash_name{$name}++; 718 $email_hash_name{$name}++;
721 $email_hash_address{$address}++; 719 $email_hash_address{$address}++;
722 } 720 }
@@ -747,7 +745,7 @@ sub add_role {
747 my ($line, $role) = @_; 745 my ($line, $role) = @_;
748 746
749 my ($name, $address) = parse_email($line); 747 my ($name, $address) = parse_email($line);
750 my $email = format_email($name, $address); 748 my $email = format_email($name, $address, $email_usename);
751 749
752 foreach my $entry (@email_to) { 750 foreach my $entry (@email_to) {
753 if ($email_remove_duplicates) { 751 if ($email_remove_duplicates) {
@@ -784,7 +782,7 @@ sub which {
784} 782}
785 783
786sub mailmap { 784sub mailmap {
787 my @lines = @_; 785 my (@lines) = @_;
788 my %hash; 786 my %hash;
789 787
790 foreach my $line (@lines) { 788 foreach my $line (@lines) {
@@ -793,14 +791,14 @@ sub mailmap {
793 $hash{$name} = $address; 791 $hash{$name} = $address;
794 } elsif ($address ne $hash{$name}) { 792 } elsif ($address ne $hash{$name}) {
795 $address = $hash{$name}; 793 $address = $hash{$name};
796 $line = format_email($name, $address); 794 $line = format_email($name, $address, $email_usename);
797 } 795 }
798 if (exists($mailmap{$name})) { 796 if (exists($mailmap{$name})) {
799 my $obj = $mailmap{$name}; 797 my $obj = $mailmap{$name};
800 foreach my $map_address (@$obj) { 798 foreach my $map_address (@$obj) {
801 if (($map_address eq $address) && 799 if (($map_address eq $address) &&
802 ($map_address ne $hash{$name})) { 800 ($map_address ne $hash{$name})) {
803 $line = format_email($name, $hash{$name}); 801 $line = format_email($name, $hash{$name}, $email_usename);
804 } 802 }
805 } 803 }
806 } 804 }
@@ -809,33 +807,44 @@ sub mailmap {
809 return @lines; 807 return @lines;
810} 808}
811 809
812sub recent_git_signoffs { 810my $printed_nogit = 0;
813 my ($file) = @_; 811my $printed_nogitdir = 0;
814 812sub has_git {
815 my $sign_offs = "";
816 my $cmd = "";
817 my $output = "";
818 my $count = 0;
819 my @lines = ();
820 my %hash;
821 my $total_sign_offs;
822
823 if (which("git") eq "") { 813 if (which("git") eq "") {
824 warn("$P: git not found. Add --nogit to options?\n"); 814 if (!$printed_nogit) {
825 return; 815 warn("$P: git not found. Add --nogit to options?\n");
816 $printed_nogit = 1;
817 }
818 return 0;
826 } 819 }
827 if (!(-d ".git")) { 820 if (!(-d ".git")) {
828 warn("$P: .git directory not found. Use a git repository for better results.\n"); 821 if (!$printed_nogitdir) {
829 warn("$P: perhaps 'git clone git://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux-2.6.git'\n"); 822 warn(".git directory not found. "
830 return; 823 . "Using a git repository produces better results.\n");
824 warn("Try Linus Torvalds' latest git repository using:\n");
825 warn("git clone git://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux-2.6.git\n");
826 $printed_nogitdir = 1;
827 }
828 return 0;
831 } 829 }
832 830