Skip to contentSkip to conversation

checkpatch.pl: use correct gitroot when running from non-top-level dir

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

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 checkpatch.pl: use correct gitroot when running from non-top-level dir

My workflow usually requires running checkpatch.pl from a subdirectory of the kernel source tree. This works for the most part, but the script will be unable to find the .git directory and will therefore refuse to run any git commands (so, e.g. commit ID verification will fail). Fix it by prepending $root to $gitroot when a root is set.

This also requires fixing one root directory assumption in a git invocation.

---
 scripts/checkpatch.pl | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)
scripts/checkpatch.pl +3 -1
index c27d2312cfc3..171c5993efb4 100755
@@ -434,6 +434,8 @@ if ($tree) {
 		print "Must be run from the top-level dir. of a kernel tree\n";
 		exit(2);
 	}
+
+	$gitroot = "$root/$gitroot";
 }
 
 my $emitted_corrupt = 0;
@@ -1131,7 +1133,7 @@ sub seed_camelcase_includes {
 	}
 
 	if (-e "$gitroot") {
-		$files = `${git_command} ls-files "include/*.h"`;
+		$files = `${git_command} ls-files "$root/include/*.h"`;
 		@include_files = split('\n', $files);
 	}
 
Signature · 1 line
2.33.0.309.g3052b89438-goog
#1 lore raw
Quoted 9 lines · Peter Collingbourne

My workflow usually requires running checkpatch.pl from a subdirectory of the kernel source tree. This works for the most part, but the script will be unable to find the .git directory and will therefore refuse to run any git commands (so, e.g. commit ID verification will fail). Fix it by prepending $root to $gitroot when a root is set.

This also requires fixing one root directory assumption in a git invocation.

Ping.

Peter

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

My workflow usually requires running checkpatch.pl from a subdirectory of the kernel source tree. This works for the most part, but the script will be unable to find the .git directory and will therefore refuse to run any git commands (so, e.g. commit ID verification will fail). Fix it by prepending $root to $gitroot when a root is set.

Quoted 4 lines
Quoted 2 lines

This also requires fixing one root directory assumption in a git invocation.

Ping.

Ping^2.

Peter