From 18ef52083d97fa87b780b06a747a544da1dcd7d8 Mon Sep 17 00:00:00 2001 From: Elyes HAOUAS Date: Sat, 29 Jan 2022 08:27:14 +0100 Subject: util/lint/checkpatch.pl: Use "gitroot" This is to reduce difference with linux v5.16. Change-Id: I3bdf880c8b6068467665865b7cf1249d1047e833 Signed-off-by: Elyes HAOUAS Reviewed-on: https://review.coreboot.org/c/coreboot/+/61470 Tested-by: build bot (Jenkins) Reviewed-by: Martin Roth --- util/lint/checkpatch.pl | 10 ++++++---- 1 file 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 = (); -- cgit v1.2.3