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 = ();
@@ -897,7 +899,7 @@ sub is_maintained_obsolete {
897899sub is_SPDX_License_valid {
898900 my ($license ) = @_ ;
899901
900- return 1 if (!$tree || which(" python" ) eq " " || !(-e " $root /scripts/spdxcheck.py" ) || !(-e " $root /.git " ));
902+ return 1 if (!$tree || which(" python" ) eq " " || !(-e " $root /scripts/spdxcheck.py" ) || !(-e " $gitroot " ));
901903
902904 my $root_path = abs_path($root );
903905 my $status = ` cd "$root_path "; echo "$license " | python scripts/spdxcheck.py -` ;
@@ -915,7 +917,7 @@ sub seed_camelcase_includes {
915917
916918 $camelcase_seeded = 1;
917919
918- if (-e " .git " ) {
920+ if (-e " $gitroot " ) {
919921 my $git_last_include_commit = ` ${git_command} log --no-merges --pretty=format:"%h%n " -1 -- include` ;
920922 chomp $git_last_include_commit ;
921923 $camelcase_cache = " .checkpatch-camelcase.git.$git_last_include_commit " ;
@@ -943,7 +945,7 @@ sub seed_camelcase_includes {
943945 return ;
944946 }
945947
946- if (-e " .git " ) {
948+ if (-e " $gitroot " ) {
947949 $files = ` ${git_command} ls-files "include/*.h"` ;
948950 @include_files = split (' \n' , $files );
949951 }
@@ -966,7 +968,7 @@ sub seed_camelcase_includes {
966968sub git_commit_info {
967969 my ($commit , $id , $desc ) = @_ ;
968970
969- return ($id , $desc ) if ((which(" git" ) eq " " ) || !(-e " .git " ));
971+ return ($id , $desc ) if ((which(" git" ) eq " " ) || !(-e " $gitroot " ));
970972
971973 my $output = ` ${git_command} log --no-color --format='%H %s ' -1 $commit 2>&1` ;
972974 $output =~ s / ^\s *// gm ;
@@ -1005,7 +1007,7 @@ sub git_commit_info {
10051007
10061008# If input is git commits, extract all commits from the commit expressions.
10071009# For example, HEAD-3 means we need check 'HEAD, HEAD~1, HEAD~2'.
1008- die " $P : No git repository found\n " if ($git && !-e " .git " );
1010+ die " $P : No git repository found\n " if ($git && !-e " $gitroot " );
10091011
10101012if ($git ) {
10111013 my @commits = ();
0 commit comments