summaryrefslogtreecommitdiff
path: root/util/lint
diff options
context:
space:
mode:
authorElyes HAOUAS <ehaouas@noos.fr>2022-01-29 08:27:14 +0100
committerMartin Roth <martinroth@google.com>2022-01-31 17:46:49 +0000
commit18ef52083d97fa87b780b06a747a544da1dcd7d8 (patch)
tree2455483ddb958ac82e0b67773787591bb8827935 /util/lint
parent249c4044c2ea97d95485ee7f75ddaf48a4c3db8f (diff)
util/lint/checkpatch.pl: Use "gitroot"
This is to reduce difference with linux v5.16. Change-Id: I3bdf880c8b6068467665865b7cf1249d1047e833 Signed-off-by: Elyes HAOUAS <ehaouas@noos.fr> Reviewed-on: https://review.coreboot.org/c/coreboot/+/61470 Tested-by: build bot (Jenkins) <no-reply@coreboot.org> Reviewed-by: Martin Roth <martinroth@google.com>
Diffstat (limited to 'util/lint')
-rwxr-xr-xutil/lint/checkpatch.pl10
1 files changed, 6 insertions, 4 deletions
diff --git a/util/lint/checkpatch.pl b/util/lint/checkpatch.pl
index 5b0c307d55..cd188e6bd4 100755
--- a/util/lint/checkpatch.pl
+++ b/util/lint/checkpatch.pl
@@ -42,6 +42,8 @@ my $list_types = 0;
my $fix = 0;
my $fix_inplace = 0;
my $root = $P; #coreboot
+my $gitroot = $ENV{'GIT_DIR'};
+$gitroot = ".git" if !defined($gitroot);
my %debug;
my %camelcase = ();
my %use_type = ();
@@ -867,7 +869,7 @@ sub seed_camelcase_includes {
$camelcase_seeded = 1;
- if (-e ".git") {
+ if (-e "$gitroot") {
my $git_last_include_commit = `git log --no-merges --pretty=format:"%h%n" -1 -- include`;
chomp $git_last_include_commit;
$camelcase_cache = ".checkpatch-camelcase.git.$git_last_include_commit";
@@ -895,7 +897,7 @@ sub seed_camelcase_includes {
return;
}
- if (-e ".git") {
+ if (-e "$gitroot") {
$files = `git ls-files "include/*.h"`;
@include_files = split('\n', $files);
}
@@ -918,7 +920,7 @@ sub seed_camelcase_includes {
sub git_commit_info {
my ($commit, $id, $desc) = @_;
- return ($id, $desc) if ((which("git") eq "") || !(-e ".git"));
+ return ($id, $desc) if ((which("git") eq "") || !(-e "$gitroot"));
my $output = `git log --no-color --format='%H %s' -1 $commit 2>&1`;
$output =~ s/^\s*//gm;
@@ -957,7 +959,7 @@ my $fixlinenr = -1;
# If input is git commits, extract all commits from the commit expressions.
# For example, HEAD-3 means we need check 'HEAD, HEAD~1, HEAD~2'.
-die "$P: No git repository found\n" if ($git && !-e ".git");
+die "$P: No git repository found\n" if ($git && !-e "$gitroot");
if ($git) {
my @commits = ();