mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: CaoRuichuang <create0818@163.com>
To: apw@canonical.com, joe@perches.com
Cc: dwaipayanray1@gmail.com, lukas.bulwahn@gmail.com,
	linux-kernel@vger.kernel.org, CaoRuichuang <create0818@163.com>
Subject: [PATCH] scripts: allow checkpatch and get_maintainer in sparse checkouts
Date: Mon,  6 Apr 2026 02:55:04 +0800	[thread overview]
Message-ID: <20260405185504.76040-1-create0818@163.com> (raw)

checkpatch.pl and get_maintainer.pl currently reject sparse checkouts because top_of_kernel_tree() insists on top-level directories such as arch/, drivers/ and fs/ being present in the working tree.

That unnecessarily blocks common patch preparation workflows using partial clones or sparse checkouts, even when the files needed by these tools are present.

Relax the tree check to require only the top-level files and directories these scripts actually need so they continue to recognize full trees while also working from sparse checkouts.

Signed-off-by: CaoRuichuang <create0818@163.com>
---
 scripts/checkpatch.pl     | 4 ++--
 scripts/get_maintainer.pl | 9 +--------
 2 files changed, 3 insertions(+), 10 deletions(-)

diff --git a/scripts/checkpatch.pl b/scripts/checkpatch.pl
index e563746..259abff 100755
--- a/scripts/checkpatch.pl
+++ b/scripts/checkpatch.pl
@@ -1397,10 +1397,10 @@ exit($exit);
 sub top_of_kernel_tree {
 	my ($root) = @_;
 
+	# Allow sparse checkouts that still contain the files these scripts need.
 	my @tree_check = (
 		"COPYING", "CREDITS", "Kbuild", "MAINTAINERS", "Makefile",
-		"README", "Documentation", "arch", "include", "drivers",
-		"fs", "init", "ipc", "kernel", "lib", "scripts",
+		"README", "Documentation", "scripts",
 	);
 
 	foreach my $check (@tree_check) {
diff --git a/scripts/get_maintainer.pl b/scripts/get_maintainer.pl
index 4414194..1d032f0 100755
--- a/scripts/get_maintainer.pl
+++ b/scripts/get_maintainer.pl
@@ -1157,6 +1157,7 @@ sub top_of_kernel_tree {
     if ($lk_path ne "" && substr($lk_path,length($lk_path)-1,1) ne "/") {
 	$lk_path .= "/";
     }
+    # Allow sparse checkouts that still contain the files these scripts need.
     if (   (-f "${lk_path}COPYING")
 	&& (-f "${lk_path}CREDITS")
 	&& (-f "${lk_path}Kbuild")
@@ -1164,14 +1165,6 @@ sub top_of_kernel_tree {
 	&& (-f "${lk_path}Makefile")
 	&& (-f "${lk_path}README")
 	&& (-d "${lk_path}Documentation")
-	&& (-d "${lk_path}arch")
-	&& (-d "${lk_path}include")
-	&& (-d "${lk_path}drivers")
-	&& (-d "${lk_path}fs")
-	&& (-d "${lk_path}init")
-	&& (-d "${lk_path}ipc")
-	&& (-d "${lk_path}kernel")
-	&& (-d "${lk_path}lib")
 	&& (-d "${lk_path}scripts")) {
 	return 1;
     }
-- 
2.39.5 (Apple Git-154)


             reply	other threads:[~2026-04-05 18:55 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-04-05 18:55 CaoRuichuang [this message]
2026-04-05 19:12 ` Joe Perches
2026-04-05 19:15 ` [PATCH v2 0/2] scripts: support sparse checkouts in checkpatch tools CaoRuichuang
2026-04-05 19:15   ` [PATCH v2 1/2] scripts: allow checkpatch and get_maintainer in sparse checkouts CaoRuichuang
2026-04-05 19:26     ` Joe Perches
2026-04-05 19:39       ` CaoRuichuang
2026-04-05 19:15   ` [PATCH v2 2/2] scripts: add sparse checkout regression test for checkpatch tools CaoRuichuang

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=20260405185504.76040-1-create0818@163.com \
    --to=create0818@163.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

all inboxes | Powered by JetHome®