linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Jacob Keller <jacob.e.keller@intel.com>
To: Joe Perches <joe@perches.com>, linux-kernel@vger.kernel.org
Cc: Andrew Morton <akpm@linux-foundation.org>
Subject: Re: [PATCH] checkpatch: use $root/.git when seeding camel case
Date: Mon, 22 Jun 2020 16:56:08 -0700	[thread overview]
Message-ID: <66793797-4be2-9c39-edb6-44f731f7c6d6@intel.com> (raw)
In-Reply-To: <fe60cadc38d430f38ff8cb3d1ca9c1f44260b59d.camel@perches.com>



On 6/22/2020 3:11 PM, Joe Perches wrote:
> On Mon, 2020-06-22 at 14:58 -0700, Jacob Keller wrote:
>> When seeding the camel case file, checkpatch.pl uses the $root directory
>> in order to find the acceptable list of allowed camel case words.
>>
>> However, if the current directory is a git repository, checkpatch.pl
>> attempts to seed using the local git directory.
>>
>> This is problematic if checkpatch.pl is passed a --root and is being run
>> from within another git repository. Rather than seeding from the
>> provided root tree, checkpatch.pl will seed using the local files. If
>> the current git repository isn't a kernel tree, this can lead to
>> unexpected warnings about camel case issues.
>>
>> Always honor the $root parameter when seeding camelcase files by using
>> "$root/.git" and changing directory to the $root before invoking git.
> []
>> diff --git a/scripts/checkpatch.pl b/scripts/checkpatch.pl
> []
>> @@ -919,8 +919,8 @@ sub seed_camelcase_includes {
>>  
>>  	$camelcase_seeded = 1;
>>  
>> -	if (-e ".git") {
>> -		my $git_last_include_commit = `${git_command} log --no-merges --pretty=format:"%h%n" -1 -- include`;
>> +	if (-e "$root/.git") {
>> +		my $git_last_include_commit = `cd $root && ${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";
>>  	} else {
>> @@ -947,9 +947,10 @@ sub seed_camelcase_includes {
>>  		return;
>>  	}
>>  
>> -	if (-e ".git") {
>> -		$files = `${git_command} ls-files "include/*.h"`;
>> +	if (-e "$root/.git") {
>> +		$files = `cd $root && ${git_command} ls-files "include/*.h"`;
>>  		@include_files = split('\n', $files);
>> +		@include_files = map("$root/$_", @include_files);
>>  	}
>>  
>>  	foreach my $file (@include_files) {
> 
> checkpatch has 4 uses of ${git_command}
> 
> Maybe git_command should be changed instead.
>
So, in part, I'm not 100% sure. In our use case, it depends on what git
is being used for.

Something like "checkpatch.pl -g HEAD", we would like to target the
local repository. Where as camelcase, we'd like to target the --root
repository.

What if, instead of this, we opt to use the local .git for camelcase
only when $root is non-empty? That way, if --root is applied, camcel
case seeding always uses --root, rather than the local tree.

Something like:

if (-e ".git" && $root eq "") for this block, so then we fall through to
the non-git style instead?

> I wonder how this interacts with the GIT_DIR environment variable.
> 

Probably poorly. I suspect it would end up looking at GIT_DIR instead of
$root/.git, despite the cd.

Thanks,
Jake

      reply	other threads:[~2020-06-22 23:56 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-06-22 21:58 [PATCH] checkpatch: use $root/.git when seeding camel case Jacob Keller
2020-06-22 22:11 ` Joe Perches
2020-06-22 23:56   ` Jacob Keller [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=66793797-4be2-9c39-edb6-44f731f7c6d6@intel.com \
    --to=jacob.e.keller@intel.com \
    --cc=akpm@linux-foundation.org \
    --cc=joe@perches.com \
    --cc=linux-kernel@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).