Commit 0f7f635b authored by Joe Perches's avatar Joe Perches Committed by Linus Torvalds

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/c5e23b45562373d632fccb8bc04e563abba4dd1d.camel@perches.comSigned-off-by: default avatarJoe Perches <joe@perches.com>
Tested-by: default avatarGeert Uytterhoeven <geert@linux-m68k.org>
Signed-off-by: default avatarAndrew Morton <akpm@linux-foundation.org>
Signed-off-by: default avatarLinus Torvalds <torvalds@linux-foundation.org>
parent 672f8871
...@@ -43,6 +43,8 @@ my $list_types = 0; ...@@ -43,6 +43,8 @@ my $list_types = 0;
my $fix = 0; my $fix = 0;
my $fix_inplace = 0; my $fix_inplace = 0;
my $root; my $root;
my $gitroot = $ENV{'GIT_DIR'};
$gitroot = ".git" if !defined($gitroot);
my %debug; my %debug;
my %camelcase = (); my %camelcase = ();
my %use_type = (); my %use_type = ();
...@@ -908,7 +910,7 @@ sub is_maintained_obsolete { ...@@ -908,7 +910,7 @@ sub is_maintained_obsolete {
sub is_SPDX_License_valid { sub is_SPDX_License_valid {
my ($license) = @_; my ($license) = @_;
return 1 if (!$tree || which("python") eq "" || !(-e "$root/scripts/spdxcheck.py") || !(-e "$root/.git")); return 1 if (!$tree || which("python") eq "" || !(-e "$root/scripts/spdxcheck.py") || !(-e "$gitroot"));
my $root_path = abs_path($root); my $root_path = abs_path($root);
my $status = `cd "$root_path"; echo "$license" | python scripts/spdxcheck.py -`; my $status = `cd "$root_path"; echo "$license" | python scripts/spdxcheck.py -`;
...@@ -926,7 +928,7 @@ sub seed_camelcase_includes { ...@@ -926,7 +928,7 @@ sub seed_camelcase_includes {
$camelcase_seeded = 1; $camelcase_seeded = 1;
if (-e ".git") { if (-e "$gitroot") {
my $git_last_include_commit = `${git_command} log --no-merges --pretty=format:"%h%n" -1 -- include`; my $git_last_include_commit = `${git_command} log --no-merges --pretty=format:"%h%n" -1 -- include`;
chomp $git_last_include_commit; chomp $git_last_include_commit;
$camelcase_cache = ".checkpatch-camelcase.git.$git_last_include_commit"; $camelcase_cache = ".checkpatch-camelcase.git.$git_last_include_commit";
...@@ -954,7 +956,7 @@ sub seed_camelcase_includes { ...@@ -954,7 +956,7 @@ sub seed_camelcase_includes {
return; return;
} }
if (-e ".git") { if (-e "$gitroot") {
$files = `${git_command} ls-files "include/*.h"`; $files = `${git_command} ls-files "include/*.h"`;
@include_files = split('\n', $files); @include_files = split('\n', $files);
} }
...@@ -987,7 +989,7 @@ sub git_is_single_file { ...@@ -987,7 +989,7 @@ sub git_is_single_file {
sub git_commit_info { sub git_commit_info {
my ($commit, $id, $desc) = @_; 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_command} log --no-color --format='%H %s' -1 $commit 2>&1`; my $output = `${git_command} log --no-color --format='%H %s' -1 $commit 2>&1`;
$output =~ s/^\s*//gm; $output =~ s/^\s*//gm;
...@@ -1026,7 +1028,7 @@ my $fixlinenr = -1; ...@@ -1026,7 +1028,7 @@ my $fixlinenr = -1;
# If input is git commits, extract all commits from the commit expressions. # 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'. # 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) { if ($git) {
my @commits = (); my @commits = ();
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment