4343my $fix = 0;
4444my $fix_inplace = 0;
4545my $root ;
46+ my $gitroot = $ENV {' GIT_DIR' };
47+ $gitroot = " .git" if !defined ($gitroot );
4648my %debug ;
4749my %camelcase = ();
4850my %use_type = ();
@@ -908,7 +910,7 @@ sub is_maintained_obsolete {
908910sub is_SPDX_License_valid {
909911 my ($license ) = @_ ;
910912
911- return 1 if (!$tree || which(" python" ) eq " " || !(-e " $root /scripts/spdxcheck.py" ) || !(-e " $root /.git " ));
913+ return 1 if (!$tree || which(" python" ) eq " " || !(-e " $root /scripts/spdxcheck.py" ) || !(-e " $gitroot " ));
912914
913915 my $root_path = abs_path($root );
914916 my $status = ` cd "$root_path "; echo "$license " | python scripts/spdxcheck.py -` ;
@@ -926,7 +928,7 @@ sub seed_camelcase_includes {
926928
927929 $camelcase_seeded = 1;
928930
929- if (-e " .git " ) {
931+ if (-e " $gitroot " ) {
930932 my $git_last_include_commit = ` ${git_command} log --no-merges --pretty=format:"%h%n " -1 -- include` ;
931933 chomp $git_last_include_commit ;
932934 $camelcase_cache = " .checkpatch-camelcase.git.$git_last_include_commit " ;
@@ -954,7 +956,7 @@ sub seed_camelcase_includes {
954956 return ;
955957 }
956958
957- if (-e " .git " ) {
959+ if (-e " $gitroot " ) {
958960 $files = ` ${git_command} ls-files "include/*.h"` ;
959961 @include_files = split (' \n' , $files );
960962 }
@@ -987,7 +989,7 @@ sub git_is_single_file {
987989sub git_commit_info {
988990 my ($commit , $id , $desc ) = @_ ;
989991
990- return ($id , $desc ) if ((which(" git" ) eq " " ) || !(-e " .git " ));
992+ return ($id , $desc ) if ((which(" git" ) eq " " ) || !(-e " $gitroot " ));
991993
992994 my $output = ` ${git_command} log --no-color --format='%H %s ' -1 $commit 2>&1` ;
993995 $output =~ s / ^\s *// gm ;
@@ -1026,7 +1028,7 @@ sub git_commit_info {
10261028
10271029# If input is git commits, extract all commits from the commit expressions.
10281030# For example, HEAD-3 means we need check 'HEAD, HEAD~1, HEAD~2'.
1029- die " $P : No git repository found\n " if ($git && !-e " .git " );
1031+ die " $P : No git repository found\n " if ($git && !-e " $gitroot " );
10301032
10311033if ($git ) {
10321034 my @commits = ();
0 commit comments