From nobody Sun Jun 14 20:11:34 2026 Received: from m16.mail.163.com (m16.mail.163.com [117.135.210.4]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 904DE2F39B9 for ; Sun, 5 Apr 2026 19:16:27 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=117.135.210.4 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1775416590; cv=none; b=q8/7Let6bh8+XqncN1blSC05fPJwwmX9cwTIrNOtQX6giiLmctNwdNtWfTm2EOFtn8heCcZmFY14LY6bqKshJHPo7tAuMEKBSdlGoeY2LAtF/61cox4ETArn302OKRgnTg9gZ6X83tPT1PuNpZPAVgFqRRQ8RulgDWqPkJWEbak= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1775416590; c=relaxed/simple; bh=iLW5FQ8sIBN65ZsHrhJUHq5xTCorO/m23KXZSkZaSqk=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=YzTzgzRt0Yn/s9aCpoIF41QD2sBvKG2I1gzk8yShrEk++bRaz1l1prApCeYQHHWs7TJBeF+ogwhzW6aDm20ORdkH1JHFssAAER3BzxtUVukFHLi/UrwSWiOPNkp5OrgVXOqqwA8ntkLLk2h4ulEqSIeE2FnGQ4zepXfMloKKy4g= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=163.com; spf=pass smtp.mailfrom=163.com; dkim=pass (1024-bit key) header.d=163.com header.i=@163.com header.b=kZv4sMOA; arc=none smtp.client-ip=117.135.210.4 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=163.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=163.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=163.com header.i=@163.com header.b="kZv4sMOA" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=163.com; s=s110527; h=From:To:Subject:Date:Message-Id:MIME-Version; bh=ly kSDwOrAdvGRx/Id+XC0xOoinmY8mQNqi5eszqFO20=; b=kZv4sMOARNmSpQFU6t eVAUDWxb5Imvlq7J6D5+0+BcXKvGFn8C5eLflPj2wNtWW/t6krwlDAcLHKPQekyO p/FmF10wbnOjtKcpw5BA0GW96sRLnIXyq387LWEIKgq2zwPYbmjFjOjUq0rxNqxd awh9CP1UDvjt08bZShXHAwE38= Received: from localhost.localdomain (unknown []) by gzsmtp3 (Coremail) with SMTP id PigvCgA3WorytNJpOg2CCA--.145S3; Mon, 06 Apr 2026 03:16:07 +0800 (CST) From: CaoRuichuang To: apw@canonical.com, joe@perches.com Cc: dwaipayanray1@gmail.com, lukas.bulwahn@gmail.com, linux-kernel@vger.kernel.org, CaoRuichuang Subject: [PATCH v2 1/2] scripts: allow checkpatch and get_maintainer in sparse checkouts Date: Mon, 6 Apr 2026 03:15:54 +0800 Message-Id: <20260405191555.80315-2-create0818@163.com> X-Mailer: git-send-email 2.39.5 (Apple Git-154) In-Reply-To: <20260405191555.80315-1-create0818@163.com> References: <20260405185504.76040-1-create0818@163.com> <20260405191555.80315-1-create0818@163.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-CM-TRANSID: PigvCgA3WorytNJpOg2CCA--.145S3 X-Coremail-Antispam: 1Uf129KBjvJXoWxJr4UXFy5Zry3urW3KrW3KFg_yoW8tw43pF 47J3W3Jr4xCr4UJw1IgF1Fqr13Ga13t3W3KFn8Wr15KFn8Kws7XrWayFn8Ja4kZFZI9FW2 qwsYq3s3Gw17WFUanT9S1TB71UUUUU7qnTZGkaVYY2UrUUUUjbIjqfuFe4nvWSU5nxnvy2 9KBjDUYxBIdaVFxhVjvjDU0xZFpf9x0zN4EiUUUUUU= X-CM-SenderInfo: pfuht3jhqyimi6rwjhhfrp/xtbCwBd5smnStPfpIQAA3s Content-Type: text/plain; charset="utf-8" checkpatch.pl and get_maintainer.pl currently reject sparse checkouts becau= se top_of_kernel_tree() insists on top-level directories such as arch/, dri= vers/ 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 p= resent. Relax the tree check to require only the top-level files and directories th= ese scripts actually need so they continue to recognize full trees while al= so working from sparse checkouts. Signed-off-by: CaoRuichuang --- 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 e56374662..259abff97 100755 --- a/scripts/checkpatch.pl +++ b/scripts/checkpatch.pl @@ -1397,10 +1397,10 @@ exit($exit); sub top_of_kernel_tree { my ($root) =3D @_; =20 + # Allow sparse checkouts that still contain the files these scripts need. my @tree_check =3D ( "COPYING", "CREDITS", "Kbuild", "MAINTAINERS", "Makefile", - "README", "Documentation", "arch", "include", "drivers", - "fs", "init", "ipc", "kernel", "lib", "scripts", + "README", "Documentation", "scripts", ); =20 foreach my $check (@tree_check) { diff --git a/scripts/get_maintainer.pl b/scripts/get_maintainer.pl index 4414194be..1d032f0e4 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 .=3D "/"; } + # Allow sparse checkouts that still contain the files these scripts ne= ed. 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; } --=20 2.39.5 (Apple Git-154) From nobody Sun Jun 14 20:11:34 2026 Received: from m16.mail.163.com (m16.mail.163.com [117.135.210.2]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 8BEA42236FD for ; Sun, 5 Apr 2026 19:16:21 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=117.135.210.2 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1775416586; cv=none; b=tkpAF1BhB8TmL3ZoDHQ1JeGc4tU+Re5AmPTvrjNTuP8MmTF9Whxhi3hfuMuo+G44fOct7+2AYc5IArBb68Ge0rJgiv4cl7N9zHgUJkSQTV89BuVgnW8ejlZneLX73H74mJMLYszZj5qzzEMvGxQpwpdTwtXnPYKYJr2Bfxbh5I0= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1775416586; c=relaxed/simple; bh=rv70oa9BlpfvyMvveLMQ051qs1rdjAK24HTFNCqVJK4=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=Lnm82ZKVWeLqKaeO0HrAcDjJx3CYFyYAZjUJ0UMLj/+11tlk7Rb4qJEJKBAOUdcaCOvSACYrRzaoJUfOkLvhwmlJPhcnJ/WjoPrJw4Ds4oThbf9FvaP2W/cjYVZIGhmXap7J/04gqVg+2CNQEgQthFptlZHrEkdsglnBL7B+/Hw= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=163.com; spf=pass smtp.mailfrom=163.com; dkim=pass (1024-bit key) header.d=163.com header.i=@163.com header.b=SYhcV6JN; arc=none smtp.client-ip=117.135.210.2 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=163.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=163.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=163.com header.i=@163.com header.b="SYhcV6JN" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=163.com; s=s110527; h=From:To:Subject:Date:Message-Id:MIME-Version; bh=2/ HvmOGEAXP/Hz2JRLEWPm3f5t6xc7QOJfJd7vslW1A=; b=SYhcV6JN0f2+vltCDC 95CHCmizIZexsLRjWZXH9J3BvQyiWYSRo1i/8FmuhO50clTP07jy1II+UMvewq4B DD3eVVOMuSp5yA0AiqwidbFop2azerDhuIENIKn9q+xBNC22fppgiXIprzcGnEnE mda5/wXSyFfvGHW9g5hGmKKOI= Received: from localhost.localdomain (unknown []) by gzsmtp3 (Coremail) with SMTP id PigvCgA3WorytNJpOg2CCA--.145S4; Mon, 06 Apr 2026 03:16:08 +0800 (CST) From: CaoRuichuang To: apw@canonical.com, joe@perches.com Cc: dwaipayanray1@gmail.com, lukas.bulwahn@gmail.com, linux-kernel@vger.kernel.org, CaoRuichuang Subject: [PATCH v2 2/2] scripts: add sparse checkout regression test for checkpatch tools Date: Mon, 6 Apr 2026 03:15:55 +0800 Message-Id: <20260405191555.80315-3-create0818@163.com> X-Mailer: git-send-email 2.39.5 (Apple Git-154) In-Reply-To: <20260405191555.80315-1-create0818@163.com> References: <20260405185504.76040-1-create0818@163.com> <20260405191555.80315-1-create0818@163.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-CM-TRANSID: PigvCgA3WorytNJpOg2CCA--.145S4 X-Coremail-Antispam: 1Uf129KBjvJXoW7Kr1fJF1DGFy5uw1kJF1xuFg_yoW8Kw48pF 4Y9w15A3y7KrZ7Zws2gF18Jry5t3ZakF45WrnFgF4rtF98tFs5JrWSkF45ZFnrAF15Ga43 Wa98X343Ka1j93JanT9S1TB71UUUUU7qnTZGkaVYY2UrUUUUjbIjqfuFe4nvWSU5nxnvy2 9KBjDUYxBIdaVFxhVjvjDU0xZFpf9x0zRt3kAUUUUU= X-CM-SenderInfo: pfuht3jhqyimi6rwjhhfrp/xtbC6Bh6s2nStPi6VgAA3i Content-Type: text/plain; charset="utf-8" Add a shell-based regression test that exercises checkpatch.pl and get_main= tainer.pl from a minimal sparse checkout style tree. This locks in the sparse checkout behavior added by the preceding patch and= catches future regressions in top_of_kernel_tree() handling for these scri= pts. Signed-off-by: CaoRuichuang --- scripts/checkpatch-sparse-checkout-test.sh | 48 ++++++++++++++++++++++ 1 file changed, 48 insertions(+) create mode 100755 scripts/checkpatch-sparse-checkout-test.sh diff --git a/scripts/checkpatch-sparse-checkout-test.sh b/scripts/checkpatc= h-sparse-checkout-test.sh new file mode 100755 index 000000000..02e2774a8 --- /dev/null +++ b/scripts/checkpatch-sparse-checkout-test.sh @@ -0,0 +1,48 @@ +#!/bin/sh -eu +# SPDX-License-Identifier: GPL-2.0 + +srctree=3D$(CDPATH=3D cd -- "$(dirname -- "$0")/.." && pwd) +tmpdir=3D$(mktemp -d) +trap 'rm -rf "$tmpdir"' EXIT + +mkdir -p "$tmpdir/Documentation/process" "$tmpdir/scripts" + +for file in COPYING CREDITS Kbuild MAINTAINERS Makefile README; do + cp "$srctree/$file" "$tmpdir/$file" +done + +cp "$srctree/Documentation/process/submitting-patches.rst" \ + "$tmpdir/Documentation/process/" +cp "$srctree/scripts/checkpatch.pl" "$tmpdir/scripts/" +cp "$srctree/scripts/get_maintainer.pl" "$tmpdir/scripts/" +cp "$srctree/scripts/spdxcheck.py" "$tmpdir/scripts/" +cp "$srctree/scripts/spelling.txt" "$tmpdir/scripts/" + +git -C "$tmpdir" init -q +git -C "$tmpdir" add \ + COPYING CREDITS Kbuild MAINTAINERS Makefile README \ + Documentation/process/submitting-patches.rst \ + scripts/checkpatch.pl scripts/get_maintainer.pl \ + scripts/spdxcheck.py scripts/spelling.txt + +checkpatch_out=3D$( + cd "$tmpdir" && + perl scripts/checkpatch.pl --file Documentation/process/submitting-patche= s.rst \ + 2>&1 || true +) + +echo "$checkpatch_out" | + grep -q "Must be run from the top-level dir. of a kernel tree" && + exit 1 + +get_maintainer_out=3D$( + cd "$tmpdir" && + perl scripts/get_maintainer.pl -f Documentation/process/submitting-patche= s.rst \ + 2>&1 +) + +echo "$get_maintainer_out" | + grep -q "The current directory does not appear to be a linux kernel sourc= e tree" && + exit 1 + +echo "$get_maintainer_out" | grep -q "Jonathan Corbet" || exit 1 --=20 2.39.5 (Apple Git-154)