All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH V2] checkpatch: Enable GIT_DIR environment use to set git repository location
@ 2020-10-18 18:45 Joe Perches
  2020-10-19  7:07 ` Geert Uytterhoeven
  0 siblings, 1 reply; 2+ messages in thread
From: Joe Perches @ 2020-10-18 18:45 UTC (permalink / raw)
  To: Linus Torvalds, Andrew Morton; +Cc: Geert Uytterhoeven, Andy Whitcroft, LKML

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.

Signed-off-by: Joe Perches <joe@perches.com>
---

V2: learn to type my own email address...

commit f5f613259f3f ("checkpatch: allow not using -f with files that are in git")
breaks the use of checkpatch with:

   Global symbol "$gitroot" requires explicit package name (did you forget to declare "my $gitroot"?) at ./scripts/checkpatch.pl line 980.
   Execution of ./scripts/checkpatch.pl aborted due to compilation errors.

An unsigned test patch exists in -next that is required for
that new commit.

So, provide a better commit description for that test patch
and sign it too...

scripts/checkpatch.pl | 12 +++++++-----
 1 file changed, 7 insertions(+), 5 deletions(-)

diff --git a/scripts/checkpatch.pl b/scripts/checkpatch.pl
index f40a81f24d43..a213cdb82ab0 100755
--- a/scripts/checkpatch.pl
+++ b/scripts/checkpatch.pl
@@ -43,6 +43,8 @@ my $list_types = 0;
 my $fix = 0;
 my $fix_inplace = 0;
 my $root;
+my $gitroot = $ENV{'GIT_DIR'};
+$gitroot = ".git" if !defined($gitroot);
 my %debug;
 my %camelcase = ();
 my %use_type = ();
@@ -908,7 +910,7 @@ sub is_maintained_obsolete {
 sub is_SPDX_License_valid {
 	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 $status = `cd "$root_path"; echo "$license" | python scripts/spdxcheck.py -`;
@@ -926,7 +928,7 @@ sub seed_camelcase_includes {
 
 	$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`;
 		chomp $git_last_include_commit;
 		$camelcase_cache = ".checkpatch-camelcase.git.$git_last_include_commit";
@@ -954,7 +956,7 @@ sub seed_camelcase_includes {
 		return;
 	}
 
-	if (-e ".git") {
+	if (-e "$gitroot") {
 		$files = `${git_command} ls-files "include/*.h"`;
 		@include_files = split('\n', $files);
 	}
@@ -987,7 +989,7 @@ sub git_is_single_file {
 sub git_commit_info {
 	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`;
 	$output =~ s/^\s*//gm;
@@ -1026,7 +1028,7 @@ my $fixlinenr = -1;
 
 # 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'.
-die "$P: No git repository found\n" if ($git && !-e ".git");
+die "$P: No git repository found\n" if ($git && !-e "$gitroot");
 
 if ($git) {
 	my @commits = ();



^ permalink raw reply related	[flat|nested] 2+ messages in thread

* Re: [PATCH V2] checkpatch: Enable GIT_DIR environment use to set git repository location
  2020-10-18 18:45 [PATCH V2] checkpatch: Enable GIT_DIR environment use to set git repository location Joe Perches
@ 2020-10-19  7:07 ` Geert Uytterhoeven
  0 siblings, 0 replies; 2+ messages in thread
From: Geert Uytterhoeven @ 2020-10-19  7:07 UTC (permalink / raw)
  To: Joe Perches; +Cc: Linus Torvalds, Andrew Morton, Andy Whitcroft, LKML

On Sun, Oct 18, 2020 at 8:45 PM Joe Perches <joe@perches.com> wrote:
> 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.
>
> Signed-off-by: Joe Perches <joe@perches.com>

Tested-by: Geert Uytterhoeven <geert@linux-m68k.org>

Gr{oetje,eeting}s,

                        Geert

-- 
Geert Uytterhoeven -- There's lots of Linux beyond ia32 -- geert@linux-m68k.org

In personal conversations with technical people, I call myself a hacker. But
when I'm talking to journalists I just say "programmer" or something like that.
                                -- Linus Torvalds

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2020-10-19  7:07 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-10-18 18:45 [PATCH V2] checkpatch: Enable GIT_DIR environment use to set git repository location Joe Perches
2020-10-19  7:07 ` Geert Uytterhoeven

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.