From patchwork Fri Mar 15 01:03:34 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jacob Keller X-Patchwork-Id: 1056797 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (mailfrom) smtp.mailfrom=osuosl.org (client-ip=140.211.166.137; helo=fraxinus.osuosl.org; envelope-from=intel-wired-lan-bounces@osuosl.org; receiver=) Authentication-Results: ozlabs.org; dmarc=fail (p=none dis=none) header.from=intel.com Received: from fraxinus.osuosl.org (smtp4.osuosl.org [140.211.166.137]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 44L6ng1VDzz9s9N for ; Fri, 15 Mar 2019 12:05:26 +1100 (AEDT) Received: from localhost (localhost [127.0.0.1]) by fraxinus.osuosl.org (Postfix) with ESMTP id 6961986D79; Fri, 15 Mar 2019 01:05:24 +0000 (UTC) X-Virus-Scanned: amavisd-new at osuosl.org Received: from fraxinus.osuosl.org ([127.0.0.1]) by localhost (.osuosl.org [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id Tkx0T90wqnvA; Fri, 15 Mar 2019 01:05:23 +0000 (UTC) Received: from ash.osuosl.org (ash.osuosl.org [140.211.166.34]) by fraxinus.osuosl.org (Postfix) with ESMTP id 80DA886C73; Fri, 15 Mar 2019 01:05:23 +0000 (UTC) X-Original-To: intel-wired-lan@lists.osuosl.org Delivered-To: intel-wired-lan@lists.osuosl.org Received: from silver.osuosl.org (smtp3.osuosl.org [140.211.166.136]) by ash.osuosl.org (Postfix) with ESMTP id 61C0C1BF963 for ; Fri, 15 Mar 2019 01:05:21 +0000 (UTC) Received: from localhost (localhost [127.0.0.1]) by silver.osuosl.org (Postfix) with ESMTP id 5E656228EA for ; Fri, 15 Mar 2019 01:05:21 +0000 (UTC) X-Virus-Scanned: amavisd-new at osuosl.org Received: from silver.osuosl.org ([127.0.0.1]) by localhost (.osuosl.org [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id 1aLGlPCH-2PL for ; Fri, 15 Mar 2019 01:05:20 +0000 (UTC) X-Greylist: domain auto-whitelisted by SQLgrey-1.7.6 Received: from mga09.intel.com (mga09.intel.com [134.134.136.24]) by silver.osuosl.org (Postfix) with ESMTPS id 921A921579 for ; Fri, 15 Mar 2019 01:05:20 +0000 (UTC) X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from fmsmga007.fm.intel.com ([10.253.24.52]) by orsmga102.jf.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 14 Mar 2019 18:05:19 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.58,480,1544515200"; d="scan'208";a="134474948" Received: from jekeller-desk.amr.corp.intel.com ([10.166.244.182]) by fmsmga007.fm.intel.com with ESMTP; 14 Mar 2019 18:05:19 -0700 From: Jacob Keller To: linux-kernel@vger.kernel.org Date: Thu, 14 Mar 2019 18:03:34 -0700 Message-Id: <20190315010334.5707-1-jacob.e.keller@intel.com> X-Mailer: git-send-email 2.18.0.219.gaf81d287a9da Subject: [Intel-wired-lan] [PATCH] checkpatch: fix camel case seeding when run with --root X-BeenThere: intel-wired-lan@osuosl.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Intel Wired Ethernet Linux Kernel Driver Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: netdev@vger.kernel.org, Intel Wired LAN , joe@perches.com MIME-Version: 1.0 Errors-To: intel-wired-lan-bounces@osuosl.org Sender: "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 --- (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) {