From: Peter Collingbourne <pcc@google.com>
To: Andy Whitcroft <apw@canonical.com>, Joe Perches <joe@perches.com>,
Dwaipayan Ray <dwaipayanray1@gmail.com>,
Lukas Bulwahn <lukas.bulwahn@gmail.com>
Cc: Peter Collingbourne <pcc@google.com>, linux-kernel@vger.kernel.org
Subject: [PATCH] checkpatch.pl: use correct gitroot when running from non-top-level dir
Date: Mon, 13 Sep 2021 16:33:24 -0700 [thread overview]
Message-ID: <20210913233325.23263-1-pcc@google.com> (raw)
My workflow usually requires running checkpatch.pl from a subdirectory
of the kernel source tree. This works for the most part, but the script
will be unable to find the .git directory and will therefore refuse to
run any git commands (so, e.g. commit ID verification will fail). Fix
it by prepending $root to $gitroot when a root is set.
This also requires fixing one root directory assumption in a git
invocation.
Signed-off-by: Peter Collingbourne <pcc@google.com>
Link: https://linux-review.googlesource.com/id/I33dc5f38e2bfcd95c8ea59933bba5305cce50404
---
scripts/checkpatch.pl | 4 +++-
1 file changed, 3 insertions(+), 1 deletion(-)
diff --git a/scripts/checkpatch.pl b/scripts/checkpatch.pl
index c27d2312cfc3..171c5993efb4 100755
--- a/scripts/checkpatch.pl
+++ b/scripts/checkpatch.pl
@@ -434,6 +434,8 @@ if ($tree) {
print "Must be run from the top-level dir. of a kernel tree\n";
exit(2);
}
+
+ $gitroot = "$root/$gitroot";
}
my $emitted_corrupt = 0;
@@ -1131,7 +1133,7 @@ sub seed_camelcase_includes {
}
if (-e "$gitroot") {
- $files = `${git_command} ls-files "include/*.h"`;
+ $files = `${git_command} ls-files "$root/include/*.h"`;
@include_files = split('\n', $files);
}
--
2.33.0.309.g3052b89438-goog
next reply other threads:[~2021-09-13 23:34 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-09-13 23:33 Peter Collingbourne [this message]
2022-02-23 22:32 ` [PATCH] checkpatch.pl: use correct gitroot when running from non-top-level dir Peter Collingbourne
2022-11-04 16:51 ` Peter Collingbourne
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=20210913233325.23263-1-pcc@google.com \
--to=pcc@google.com \
--cc=apw@canonical.com \
--cc=dwaipayanray1@gmail.com \
--cc=joe@perches.com \
--cc=linux-kernel@vger.kernel.org \
--cc=lukas.bulwahn@gmail.com \
/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