Skip to content

Commit 0f7f635

Browse files
JoePerchestorvalds
authored andcommitted
checkpatch: enable GIT_DIR environment use to set git repository location
If set, use the environment variable GIT_DIR to change the default .git location of the kernel git tree. If GIT_DIR is unset, keep using the current ".git" default. Link: https://lkml.kernel.org/r/[email protected] Signed-off-by: Joe Perches <[email protected]> Tested-by: Geert Uytterhoeven <[email protected]> Signed-off-by: Andrew Morton <[email protected]> Signed-off-by: Linus Torvalds <[email protected]>
1 parent 672f887 commit 0f7f635

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 = ();
@@ -908,7 +910,7 @@ sub is_maintained_obsolete {
908910
sub 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 {
987989
sub 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

10311033
if ($git) {
10321034
my @commits = ();

0 commit comments

Comments
 (0)