Skip to contentSkip to conversation

get_maintainer.pl: support running from non-top-level dir

PATCH In review Peter Collingbourne 1 participant 3 messages Sep 13, 2021 – Nov 4, 2022 GET_MAINTAINER script

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 get_maintainer.pl: support running from non-top-level dir

My workflow usually involves running scripts from a subdirectory of the kernel source tree. This fails with get_maintainer.pl because it assumes that it runs from the top level. Fix this assumption by setting $lk_path appropriately based on a check of $0 similar to what is in checkpatch.pl.

This also requires fixing the VCS available checks to also check $lk_path.

---
 scripts/get_maintainer.pl | 8 ++++++--
 1 file changed, 6 insertions(+), 2 deletions(-)
scripts/get_maintainer.pl +6 -2
index 2075db0c08b8..47474cb85ea7 100755
@@ -114,7 +114,7 @@ my %VCS_cmds;
 
 my %VCS_cmds_git = (
     "execute_cmd" => \&git_execute_cmd,
-    "available" => '(which("git") ne "") && (-e ".git")',
+    "available" => '(which("git") ne "") && (-e "${lk_path}.git")',
     "find_signers_cmd" =>
 	"git log --no-color --follow --since=\$email_git_since " .
 	    '--numstat --no-merges ' .
@@ -154,7 +154,7 @@ my %VCS_cmds_git = (
 
 my %VCS_cmds_hg = (
     "execute_cmd" => \&hg_execute_cmd,
-    "available" => '(which("hg") ne "") && (-d ".hg")',
+    "available" => '(which("hg") ne "") && (-d "${lk_path}.hg")',
     "find_signers_cmd" =>
 	"hg log --date=\$email_hg_since " .
 	    "--template='HgCommit: {node}\\n" .
@@ -333,6 +333,10 @@ if ($email &&
     die "$P: Please select at least 1 email option\n";
 }
 
+if ($0 =~ m@(.*)/scripts/[^/]*$@ && top_of_kernel_tree($1)) {
+    $lk_path = "$1/";
+}
+
 if ($tree && !top_of_kernel_tree($lk_path)) {
     die "$P: The current directory does not appear to be "
 	. "a linux kernel source tree.\n";
Signature · 1 line
2.33.0.309.g3052b89438-goog
#1 lore raw
Quoted 7 lines · Peter Collingbourne

My workflow usually involves running scripts from a subdirectory of the kernel source tree. This fails with get_maintainer.pl because it assumes that it runs from the top level. Fix this assumption by setting $lk_path appropriately based on a check of $0 similar to what is in checkpatch.pl.

This also requires fixing the VCS available checks to also check $lk_path.

Ping.

Peter

#2 lore raw
Quoted 11 lines · Peter Collingbourne
Quoted 7 lines · Peter Collingbourne

My workflow usually involves running scripts from a subdirectory of the kernel source tree. This fails with get_maintainer.pl because it assumes that it runs from the top level. Fix this assumption by setting $lk_path appropriately based on a check of $0 similar to what is in checkpatch.pl.

This also requires fixing the VCS available checks to also check $lk_path.

Ping.

Ping^2.

Peter