All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] checkpatch: fix camel case seeding when run with --root
@ 2019-03-15  1:03 ` Jacob Keller
  0 siblings, 0 replies; 9+ messages in thread
From: Jacob Keller @ 2019-03-15  1:03 UTC (permalink / raw)
  To: linux-kernel; +Cc: Intel Wired LAN, netdev, Jacob Keller, joe

checkpatch.pl avoids warning about camel case of some definitions by
seeding a file that tracks all of the currently committed camel case
definitions.

To build this seed file, checkpatch.pl decides between using git or the
--root parameter.

This works as long as you don't run checkpatch.pl from within
a different git tree that is not the Linux kernel.

In this case, the check for ".git" will return true, and checkpatch will
attempt to seed a camel case file using the current directory. This
works fine if --root is not provided, but can result in an incorrect
camel case seed file resulting in false positive warnings.

Fix this by checking for $root/.git instead, so that we use the --root
parameter properly when seeding the camel case list.

Additionally, when generating the list of files to be checked, prefix
the $root path so that the correct file will be found.

These changes allow checkpatch.pl to honor the --root parameter even if
being run from within another git repository.

Signed-off-by: Jacob Keller <jacob.e.keller@intel.com>
---
(Resending with a not-invalid address for the netdev mailing list...)

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

diff --git a/scripts/checkpatch.pl b/scripts/checkpatch.pl
index d0001fd1112d..358add495e18 100755
--- a/scripts/checkpatch.pl
+++ b/scripts/checkpatch.pl
@@ -903,8 +903,8 @@ sub seed_camelcase_includes {
 
 	$camelcase_seeded = 1;
 
-	if (-e ".git") {
-		my $git_last_include_commit = `git log --no-merges --pretty=format:"%h%n" -1 -- include`;
+	if (-e "$root/.git") {
+		my $git_last_include_commit = `cd $root && git log --no-merges --pretty=format:"%h%n" -1 -- include`;
 		chomp $git_last_include_commit;
 		$camelcase_cache = ".checkpatch-camelcase.git.$git_last_include_commit";
 	} else {
@@ -931,9 +931,10 @@ sub seed_camelcase_includes {
 		return;
 	}
 
-	if (-e ".git") {
-		$files = `git ls-files "include/*.h"`;
+	if (-e "$root/.git") {
+		$files = `cd $root && git ls-files "include/*.h"`;
 		@include_files = split('\n', $files);
+		@include_files = map("$root/$_", @include_files);
 	}
 
 	foreach my $file (@include_files) {
-- 
2.18.0.219.gaf81d287a9da


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

* [Intel-wired-lan] [PATCH] checkpatch: fix camel case seeding when run with --root
@ 2019-03-15  1:03 ` Jacob Keller
  0 siblings, 0 replies; 9+ messages in thread
From: Jacob Keller @ 2019-03-15  1:03 UTC (permalink / raw)
  To: intel-wired-lan

checkpatch.pl avoids warning about camel case of some definitions by
seeding a file that tracks all of the currently committed camel case
definitions.

To build this seed file, checkpatch.pl decides between using git or the
--root parameter.

This works as long as you don't run checkpatch.pl from within
a different git tree that is not the Linux kernel.

In this case, the check for ".git" will return true, and checkpatch will
attempt to seed a camel case file using the current directory. This
works fine if --root is not provided, but can result in an incorrect
camel case seed file resulting in false positive warnings.

Fix this by checking for $root/.git instead, so that we use the --root
parameter properly when seeding the camel case list.

Additionally, when generating the list of files to be checked, prefix
the $root path so that the correct file will be found.

These changes allow checkpatch.pl to honor the --root parameter even if
being run from within another git repository.

Signed-off-by: Jacob Keller <jacob.e.keller@intel.com>
---
(Resending with a not-invalid address for the netdev mailing list...)

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

diff --git a/scripts/checkpatch.pl b/scripts/checkpatch.pl
index d0001fd1112d..358add495e18 100755
--- a/scripts/checkpatch.pl
+++ b/scripts/checkpatch.pl
@@ -903,8 +903,8 @@ sub seed_camelcase_includes {
 
 	$camelcase_seeded = 1;
 
-	if (-e ".git") {
-		my $git_last_include_commit = `git log --no-merges --pretty=format:"%h%n" -1 -- include`;
+	if (-e "$root/.git") {
+		my $git_last_include_commit = `cd $root && git log --no-merges --pretty=format:"%h%n" -1 -- include`;
 		chomp $git_last_include_commit;
 		$camelcase_cache = ".checkpatch-camelcase.git.$git_last_include_commit";
 	} else {
@@ -931,9 +931,10 @@ sub seed_camelcase_includes {
 		return;
 	}
 
-	if (-e ".git") {
-		$files = `git ls-files "include/*.h"`;
+	if (-e "$root/.git") {
+		$files = `cd $root && git ls-files "include/*.h"`;
 		@include_files = split('\n', $files);
+		@include_files = map("$root/$_", @include_files);
 	}
 
 	foreach my $file (@include_files) {
-- 
2.18.0.219.gaf81d287a9da


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

* RE: [PATCH] checkpatch: fix camel case seeding when run with --root
  2019-03-15  1:03 ` [Intel-wired-lan] " Jacob Keller
@ 2019-03-20 20:09   ` Keller, Jacob E
  -1 siblings, 0 replies; 9+ messages in thread
From: Keller, Jacob E @ 2019-03-20 20:09 UTC (permalink / raw)
  To: linux-kernel, apw, Joe Perches; +Cc: Intel Wired LAN, netdev

> -----Original Message-----
> From: Keller, Jacob E
> Sent: Thursday, March 14, 2019 6:04 PM
> To: linux-kernel@vger.kernel.org
> Cc: Intel Wired LAN <intel-wired-lan@lists.osuosl.org>; netdev@vger.kernel.org;
> Keller, Jacob E <jacob.e.keller@intel.com>; joe@perches.com
> Subject: [PATCH] checkpatch: fix camel case seeding when run with --root
> 
> checkpatch.pl avoids warning about camel case of some definitions by
> seeding a file that tracks all of the currently committed camel case
> definitions.
> 
> To build this seed file, checkpatch.pl decides between using git or the
> --root parameter.
> 
> This works as long as you don't run checkpatch.pl from within
> a different git tree that is not the Linux kernel.
> 
> In this case, the check for ".git" will return true, and checkpatch will
> attempt to seed a camel case file using the current directory. This
> works fine if --root is not provided, but can result in an incorrect
> camel case seed file resulting in false positive warnings.
> 
> Fix this by checking for $root/.git instead, so that we use the --root
> parameter properly when seeding the camel case list.
> 
> Additionally, when generating the list of files to be checked, prefix
> the $root path so that the correct file will be found.
> 
> These changes allow checkpatch.pl to honor the --root parameter even if
> being run from within another git repository.
> 
> Signed-off-by: Jacob Keller <jacob.e.keller@intel.com>
> ---
> (Resending with a not-invalid address for the netdev mailing list...)
> 

Ping? Andy? Joe?

This is a re-write of a rather old (couple of years old...) fix that I've been meaning to get around to submitting.

I'd like to have this picked up since it resolves issues with using --root while inside another git tree.

Thanks,
Jake

>  scripts/checkpatch.pl | 9 +++++----
>  1 file changed, 5 insertions(+), 4 deletions(-)
> 
> diff --git a/scripts/checkpatch.pl b/scripts/checkpatch.pl
> index d0001fd1112d..358add495e18 100755
> --- a/scripts/checkpatch.pl
> +++ b/scripts/checkpatch.pl
> @@ -903,8 +903,8 @@ sub seed_camelcase_includes {
> 
>  	$camelcase_seeded = 1;
> 
> -	if (-e ".git") {
> -		my $git_last_include_commit = `git log --no-merges --
> pretty=format:"%h%n" -1 -- include`;
> +	if (-e "$root/.git") {
> +		my $git_last_include_commit = `cd $root && git log --no-merges --
> pretty=format:"%h%n" -1 -- include`;
>  		chomp $git_last_include_commit;
>  		$camelcase_cache = ".checkpatch-
> camelcase.git.$git_last_include_commit";
>  	} else {
> @@ -931,9 +931,10 @@ sub seed_camelcase_includes {
>  		return;
>  	}
> 
> -	if (-e ".git") {
> -		$files = `git ls-files "include/*.h"`;
> +	if (-e "$root/.git") {
> +		$files = `cd $root && git ls-files "include/*.h"`;
>  		@include_files = split('\n', $files);
> +		@include_files = map("$root/$_", @include_files);
>  	}
> 
>  	foreach my $file (@include_files) {
> --
> 2.18.0.219.gaf81d287a9da


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

* [Intel-wired-lan] [PATCH] checkpatch: fix camel case seeding when run with --root
@ 2019-03-20 20:09   ` Keller, Jacob E
  0 siblings, 0 replies; 9+ messages in thread
From: Keller, Jacob E @ 2019-03-20 20:09 UTC (permalink / raw)
  To: intel-wired-lan

> -----Original Message-----
> From: Keller, Jacob E
> Sent: Thursday, March 14, 2019 6:04 PM
> To: linux-kernel at vger.kernel.org
> Cc: Intel Wired LAN <intel-wired-lan@lists.osuosl.org>; netdev at vger.kernel.org;
> Keller, Jacob E <jacob.e.keller@intel.com>; joe at perches.com
> Subject: [PATCH] checkpatch: fix camel case seeding when run with --root
> 
> checkpatch.pl avoids warning about camel case of some definitions by
> seeding a file that tracks all of the currently committed camel case
> definitions.
> 
> To build this seed file, checkpatch.pl decides between using git or the
> --root parameter.
> 
> This works as long as you don't run checkpatch.pl from within
> a different git tree that is not the Linux kernel.
> 
> In this case, the check for ".git" will return true, and checkpatch will
> attempt to seed a camel case file using the current directory. This
> works fine if --root is not provided, but can result in an incorrect
> camel case seed file resulting in false positive warnings.
> 
> Fix this by checking for $root/.git instead, so that we use the --root
> parameter properly when seeding the camel case list.
> 
> Additionally, when generating the list of files to be checked, prefix
> the $root path so that the correct file will be found.
> 
> These changes allow checkpatch.pl to honor the --root parameter even if
> being run from within another git repository.
> 
> Signed-off-by: Jacob Keller <jacob.e.keller@intel.com>
> ---
> (Resending with a not-invalid address for the netdev mailing list...)
> 

Ping? Andy? Joe?

This is a re-write of a rather old (couple of years old...) fix that I've been meaning to get around to submitting.

I'd like to have this picked up since it resolves issues with using --root while inside another git tree.

Thanks,
Jake

>  scripts/checkpatch.pl | 9 +++++----
>  1 file changed, 5 insertions(+), 4 deletions(-)
> 
> diff --git a/scripts/checkpatch.pl b/scripts/checkpatch.pl
> index d0001fd1112d..358add495e18 100755
> --- a/scripts/checkpatch.pl
> +++ b/scripts/checkpatch.pl
> @@ -903,8 +903,8 @@ sub seed_camelcase_includes {
> 
>  	$camelcase_seeded = 1;
> 
> -	if (-e ".git") {
> -		my $git_last_include_commit = `git log --no-merges --
> pretty=format:"%h%n" -1 -- include`;
> +	if (-e "$root/.git") {
> +		my $git_last_include_commit = `cd $root && git log --no-merges --
> pretty=format:"%h%n" -1 -- include`;
>  		chomp $git_last_include_commit;
>  		$camelcase_cache = ".checkpatch-
> camelcase.git.$git_last_include_commit";
>  	} else {
> @@ -931,9 +931,10 @@ sub seed_camelcase_includes {
>  		return;
>  	}
> 
> -	if (-e ".git") {
> -		$files = `git ls-files "include/*.h"`;
> +	if (-e "$root/.git") {
> +		$files = `cd $root && git ls-files "include/*.h"`;
>  		@include_files = split('\n', $files);
> +		@include_files = map("$root/$_", @include_files);
>  	}
> 
>  	foreach my $file (@include_files) {
> --
> 2.18.0.219.gaf81d287a9da


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

* Re: [PATCH] checkpatch: fix camel case seeding when run with --root
  2019-03-20 20:09   ` [Intel-wired-lan] " Keller, Jacob E
@ 2019-03-20 21:18     ` Joe Perches
  -1 siblings, 0 replies; 9+ messages in thread
From: Joe Perches @ 2019-03-20 21:18 UTC (permalink / raw)
  To: Keller, Jacob E, linux-kernel, apw, Joe Perches; +Cc: Intel Wired LAN, netdev

On Wed, 2019-03-20 at 20:09 +0000, Keller, Jacob E wrote:
> > -----Original Message-----
> > From: Keller, Jacob E
> > Sent: Thursday, March 14, 2019 6:04 PM
> > To: linux-kernel@vger.kernel.org
> > Cc: Intel Wired LAN <intel-wired-lan@lists.osuosl.org>; netdev@vger.kernel.org;
> > Keller, Jacob E <jacob.e.keller@intel.com>; joe@perches.com
> > Subject: [PATCH] checkpatch: fix camel case seeding when run with --root
> > 
> > checkpatch.pl avoids warning about camel case of some definitions by
> > seeding a file that tracks all of the currently committed camel case
> > definitions.
> > 
> > To build this seed file, checkpatch.pl decides between using git or the
> > --root parameter.
> > 
> > This works as long as you don't run checkpatch.pl from within
> > a different git tree that is not the Linux kernel.

Odd use case, but I'll forward it on as it doesn't
seem to have any other effect.

cheers, Joe


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

* [Intel-wired-lan] [PATCH] checkpatch: fix camel case seeding when run with --root
@ 2019-03-20 21:18     ` Joe Perches
  0 siblings, 0 replies; 9+ messages in thread
From: Joe Perches @ 2019-03-20 21:18 UTC (permalink / raw)
  To: intel-wired-lan

On Wed, 2019-03-20 at 20:09 +0000, Keller, Jacob E wrote:
> > -----Original Message-----
> > From: Keller, Jacob E
> > Sent: Thursday, March 14, 2019 6:04 PM
> > To: linux-kernel at vger.kernel.org
> > Cc: Intel Wired LAN <intel-wired-lan@lists.osuosl.org>; netdev at vger.kernel.org;
> > Keller, Jacob E <jacob.e.keller@intel.com>; joe at perches.com
> > Subject: [PATCH] checkpatch: fix camel case seeding when run with --root
> > 
> > checkpatch.pl avoids warning about camel case of some definitions by
> > seeding a file that tracks all of the currently committed camel case
> > definitions.
> > 
> > To build this seed file, checkpatch.pl decides between using git or the
> > --root parameter.
> > 
> > This works as long as you don't run checkpatch.pl from within
> > a different git tree that is not the Linux kernel.

Odd use case, but I'll forward it on as it doesn't
seem to have any other effect.

cheers, Joe


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

* RE: [PATCH] checkpatch: fix camel case seeding when run with --root
  2019-03-20 21:18     ` [Intel-wired-lan] " Joe Perches
@ 2019-03-20 22:24       ` Keller, Jacob E
  -1 siblings, 0 replies; 9+ messages in thread
From: Keller, Jacob E @ 2019-03-20 22:24 UTC (permalink / raw)
  To: Joe Perches, linux-kernel, apw, Joe Perches; +Cc: Intel Wired LAN, netdev

> -----Original Message-----
> From: Joe Perches [mailto:joe@perches.com]
> Sent: Wednesday, March 20, 2019 2:18 PM
> To: Keller, Jacob E <jacob.e.keller@intel.com>; linux-kernel@vger.kernel.org;
> apw@canonical.com; Joe Perches <golf@perches.com>
> Cc: Intel Wired LAN <intel-wired-lan@lists.osuosl.org>; netdev@vger.kernel.org
> Subject: Re: [PATCH] checkpatch: fix camel case seeding when run with --root
> 
> On Wed, 2019-03-20 at 20:09 +0000, Keller, Jacob E wrote:
> > > -----Original Message-----
> > > From: Keller, Jacob E
> > > Sent: Thursday, March 14, 2019 6:04 PM
> > > To: linux-kernel@vger.kernel.org
> > > Cc: Intel Wired LAN <intel-wired-lan@lists.osuosl.org>; netdev@vger.kernel.org;
> > > Keller, Jacob E <jacob.e.keller@intel.com>; joe@perches.com
> > > Subject: [PATCH] checkpatch: fix camel case seeding when run with --root
> > >
> > > checkpatch.pl avoids warning about camel case of some definitions by
> > > seeding a file that tracks all of the currently committed camel case
> > > definitions.
> > >
> > > To build this seed file, checkpatch.pl decides between using git or the
> > > --root parameter.
> > >
> > > This works as long as you don't run checkpatch.pl from within
> > > a different git tree that is not the Linux kernel.
> 
> Odd use case, but I'll forward it on as it doesn't
> seem to have any other effect.
> 
> cheers, Joe

We run checkpatch.pl on Linux driver code which is out-of-tree to start with, and then will eventually be migrated into the in-tree kernel later as we develop it.

Without this patch, the use of checkpatch.pl with --root causes bogus hits with camel case issues.

Thanks,
Jake

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

* [Intel-wired-lan] [PATCH] checkpatch: fix camel case seeding when run with --root
@ 2019-03-20 22:24       ` Keller, Jacob E
  0 siblings, 0 replies; 9+ messages in thread
From: Keller, Jacob E @ 2019-03-20 22:24 UTC (permalink / raw)
  To: intel-wired-lan

> -----Original Message-----
> From: Joe Perches [mailto:joe at perches.com]
> Sent: Wednesday, March 20, 2019 2:18 PM
> To: Keller, Jacob E <jacob.e.keller@intel.com>; linux-kernel at vger.kernel.org;
> apw at canonical.com; Joe Perches <golf@perches.com>
> Cc: Intel Wired LAN <intel-wired-lan@lists.osuosl.org>; netdev at vger.kernel.org
> Subject: Re: [PATCH] checkpatch: fix camel case seeding when run with --root
> 
> On Wed, 2019-03-20 at 20:09 +0000, Keller, Jacob E wrote:
> > > -----Original Message-----
> > > From: Keller, Jacob E
> > > Sent: Thursday, March 14, 2019 6:04 PM
> > > To: linux-kernel at vger.kernel.org
> > > Cc: Intel Wired LAN <intel-wired-lan@lists.osuosl.org>; netdev at vger.kernel.org;
> > > Keller, Jacob E <jacob.e.keller@intel.com>; joe at perches.com
> > > Subject: [PATCH] checkpatch: fix camel case seeding when run with --root
> > >
> > > checkpatch.pl avoids warning about camel case of some definitions by
> > > seeding a file that tracks all of the currently committed camel case
> > > definitions.
> > >
> > > To build this seed file, checkpatch.pl decides between using git or the
> > > --root parameter.
> > >
> > > This works as long as you don't run checkpatch.pl from within
> > > a different git tree that is not the Linux kernel.
> 
> Odd use case, but I'll forward it on as it doesn't
> seem to have any other effect.
> 
> cheers, Joe

We run checkpatch.pl on Linux driver code which is out-of-tree to start with, and then will eventually be migrated into the in-tree kernel later as we develop it.

Without this patch, the use of checkpatch.pl with --root causes bogus hits with camel case issues.

Thanks,
Jake

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

* [PATCH] checkpatch: fix camel case seeding when run with --root
@ 2019-03-15  1:01 Jacob Keller
  0 siblings, 0 replies; 9+ messages in thread
From: Jacob Keller @ 2019-03-15  1:01 UTC (permalink / raw)
  To: linux-kernel; +Cc: Intel Wired LAN, net-next, Jacob Keller, joe

checkpatch.pl avoids warning about camel case of some definitions by
seeding a file that tracks all of the currently committed camel case
definitions.

To build this seed file, checkpatch.pl decides between using git or the
--root parameter.

This works as long as you don't run checkpatch.pl from within
a different git tree that is not the Linux kernel.

In this case, the check for ".git" will return true, and checkpatch will
attempt to seed a camel case file using the current directory. This
works fine if --root is not provided, but can result in an incorrect
camel case seed file resulting in false positive warnings.

Fix this by checking for $root/.git instead, so that we use the --root
parameter properly when seeding the camel case list.

Additionally, when generating the list of files to be checked, prefix
the $root path so that the correct file will be found.

These changes allow checkpatch.pl to honor the --root parameter even if
being run from within another git repository.

Signed-off-by: Jacob Keller <jacob.e.keller@intel.com>
---

I sent this a long time ago, https://patchwork.ozlabs.org/patch/663831/ but
it was never noticed or reviewed.

I thought I'd dredge it back up and write a better description of the
problem and the fix.

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

diff --git a/scripts/checkpatch.pl b/scripts/checkpatch.pl
index d0001fd1112d..358add495e18 100755
--- a/scripts/checkpatch.pl
+++ b/scripts/checkpatch.pl
@@ -903,8 +903,8 @@ sub seed_camelcase_includes {
 
 	$camelcase_seeded = 1;
 
-	if (-e ".git") {
-		my $git_last_include_commit = `git log --no-merges --pretty=format:"%h%n" -1 -- include`;
+	if (-e "$root/.git") {
+		my $git_last_include_commit = `cd $root && git log --no-merges --pretty=format:"%h%n" -1 -- include`;
 		chomp $git_last_include_commit;
 		$camelcase_cache = ".checkpatch-camelcase.git.$git_last_include_commit";
 	} else {
@@ -931,9 +931,10 @@ sub seed_camelcase_includes {
 		return;
 	}
 
-	if (-e ".git") {
-		$files = `git ls-files "include/*.h"`;
+	if (-e "$root/.git") {
+		$files = `cd $root && git ls-files "include/*.h"`;
 		@include_files = split('\n', $files);
+		@include_files = map("$root/$_", @include_files);
 	}
 
 	foreach my $file (@include_files) {
-- 
2.18.0.219.gaf81d287a9da


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

end of thread, other threads:[~2019-03-20 22:24 UTC | newest]

Thread overview: 9+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-03-15  1:03 [PATCH] checkpatch: fix camel case seeding when run with --root Jacob Keller
2019-03-15  1:03 ` [Intel-wired-lan] " Jacob Keller
2019-03-20 20:09 ` Keller, Jacob E
2019-03-20 20:09   ` [Intel-wired-lan] " Keller, Jacob E
2019-03-20 21:18   ` Joe Perches
2019-03-20 21:18     ` [Intel-wired-lan] " Joe Perches
2019-03-20 22:24     ` Keller, Jacob E
2019-03-20 22:24       ` [Intel-wired-lan] " Keller, Jacob E
  -- strict thread matches above, loose matches on Subject: below --
2019-03-15  1:01 Jacob Keller

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.