Skip to content
This repository was archived by the owner on Nov 21, 2022. It is now read-only.

Commit 772cd08

Browse files
JoePerchessfrothwell
authored andcommitted
checkpatch: test $GIT_DIR changes
Link: http://lkml.kernel.org/r/318ca0e0c755cc31c288d7f8769817da4dc60bda.camel@perches.com Signed-off-by: Andrew Morton <akpm@linux-foundation.org> Signed-off-by: Stephen Rothwell <sfr@canb.auug.org.au>
1 parent 9cb1fd0 commit 772cd08

File tree

1 file changed

+7
-5
lines changed

1 file changed

+7
-5
lines changed

scripts/checkpatch.pl

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,8 @@
4343
my $fix = 0;
4444
my $fix_inplace = 0;
4545
my $root;
46+
my $gitroot = $ENV{'GIT_DIR'};
47+
$gitroot = ".git" if !defined($gitroot);
4648
my %debug;
4749
my %camelcase = ();
4850
my %use_type = ();
@@ -897,7 +899,7 @@ sub is_maintained_obsolete {
897899
sub 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 {
966968
sub 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

10101012
if ($git) {
10111013
my @commits = ();

0 commit comments

Comments
 (0)