Skip to content

Commit

Permalink
get_maintainer.pl: reduce need for command-line option -f
Browse files Browse the repository at this point in the history
If a vcs is used, look to see if the vcs tracks the file specified and
so the -f option becomes optional.

Link: http://lkml.kernel.org/r/7c86a8df0d48770c45778a43b6b3e4627b2a90ee.1469746395.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>
  • Loading branch information
Joe Perches authored and Linus Torvalds committed Aug 2, 2016
1 parent 750afe7 commit 4cad35a
Showing 1 changed file with 19 additions and 1 deletion.
20 changes: 19 additions & 1 deletion scripts/get_maintainer.pl
Original file line number Diff line number Diff line change
Expand Up @@ -133,6 +133,7 @@
"author_pattern" => "^GitAuthor: (.*)",
"subject_pattern" => "^GitSubject: (.*)",
"stat_pattern" => "^(\\d+)\\t(\\d+)\\t\$file\$",
"file_exists_cmd" => "git ls-files \$file",
);

my %VCS_cmds_hg = (
Expand Down Expand Up @@ -161,6 +162,7 @@
"author_pattern" => "^HgAuthor: (.*)",
"subject_pattern" => "^HgSubject: (.*)",
"stat_pattern" => "^(\\d+)\t(\\d+)\t\$file\$",
"file_exists_cmd" => "hg files \$file",
);

my $conf = which_conf(".get_maintainer.conf");
Expand Down Expand Up @@ -430,7 +432,7 @@ sub read_mailmap {
die "$P: file '${file}' not found\n";
}
}
if ($from_filename) {
if ($from_filename || vcs_file_exists($file)) {
$file =~ s/^\Q${cur_path}\E//; #strip any absolute path
$file =~ s/^\Q${lk_path}\E//; #or the path to the lk tree
push(@files, $file);
Expand Down Expand Up @@ -2124,6 +2126,22 @@ sub vcs_file_blame {
}
}

sub vcs_file_exists {
my ($file) = @_;

my $exists;

my $vcs_used = vcs_exists();
return 0 if (!$vcs_used);

my $cmd = $VCS_cmds{"file_exists_cmd"};
$cmd =~ s/(\$\w+)/$1/eeg; # interpolate $cmd

$exists = &{$VCS_cmds{"execute_cmd"}}($cmd);

return $exists;
}

sub uniq {
my (@parms) = @_;

Expand Down

0 comments on commit 4cad35a

Please sign in to comment.