Received: by 2002:ac0:a874:0:0:0:0:0 with SMTP id c49csp7872ima; Thu, 14 Mar 2019 18:03:31 -0700 (PDT) X-Google-Smtp-Source: APXvYqwb6FFBwVZB6S+JtVwuxCZJ2uLjNwtOO6P8cqKy1z7cr9yjI2xQ3/S3uAMz37bM/Rw0HtE6 X-Received: by 2002:a63:1156:: with SMTP id 22mr726925pgr.357.1552611810871; Thu, 14 Mar 2019 18:03:30 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1552611810; cv=none; d=google.com; s=arc-20160816; b=C8tFsYQui6Uq62F2EqiQbwf7S9HI0rBsVhwN4utWyq57VY3/6PZOeu6v860RSmQjrb 6zQlSMw+FIE5b5CUknv/YP35vjYNxYYgpPIQmlt1hSAE4XvCpoQnShMaXydf5VTsG2LT AxEIJZhT2GULGfXGlSe7pgW1EVZg7t24bclEzAAwN/csaLX6Vnov7w72UDdZhGbkoeSq Jf7pkK8Td0Kz0jbOVlC0U9pDMdyTE3gcvWgR3LLRzot9AvOUfERsALbqEQuPefw+MCRf JPRCBtD2/LQcehMMOwVVDUw+AVAX2ny2EWrs2jL8AGOcqlLTvl9uDm9Wm+k3bbNTKkP0 KvyA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:message-id:date:subject:cc:to:from; bh=q9Q6CMtN4emekYqxYfHieTeK0f8GjS4ok+9rR1TRlVI=; b=ipWcQ/slOW5D2oXw0oRgLvS0bCsjrtxzhlWbWXHX7RgYwVMAGb5Gr1HlPr0b3w+uvy FAioIcTVZD3/m7tbgxtbbLdTXw0zDip0gHBjzXbKjKN2akKoUUDOQFImgJqp6XbRbGm8 AP5fYzz1GrP0K1DrY4GTVKucM3/p4LAC21h1Li9nICnKlRDFbF/uqa/bpdbJfhLa2Wpd TTbhsVT/aj0ZmLIu5Xq3k65ZrM+vMbdZty+o9M71UVOTNyNc9ys7eG9Oj7mwJCL0j8uO 9E+9dFpfTYPIJhg6YJx3vQ4R+7/FXXlhvGxfR357H3u0R7D2eYkOAy/xqUKFjNFuqnEW 02fg== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=intel.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id f2si473494pgs.575.2019.03.14.18.03.16; Thu, 14 Mar 2019 18:03:30 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=intel.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728267AbfCOBB1 (ORCPT + 99 others); Thu, 14 Mar 2019 21:01:27 -0400 Received: from mga11.intel.com ([192.55.52.93]:38888 "EHLO mga11.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728187AbfCOBB0 (ORCPT ); Thu, 14 Mar 2019 21:01:26 -0400 X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from orsmga006.jf.intel.com ([10.7.209.51]) by fmsmga102.fm.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 14 Mar 2019 18:01:26 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.58,480,1544515200"; d="scan'208";a="127093664" Received: from jekeller-desk.amr.corp.intel.com ([10.166.244.182]) by orsmga006.jf.intel.com with ESMTP; 14 Mar 2019 18:01:26 -0700 From: Jacob Keller To: linux-kernel@vger.kernel.org Cc: Intel Wired LAN , net-next@vger.kernel.org, Jacob Keller , joe@perches.com Subject: [PATCH] checkpatch: fix camel case seeding when run with --root Date: Thu, 14 Mar 2019 18:01:23 -0700 Message-Id: <20190315010123.4334-1-jacob.e.keller@intel.com> X-Mailer: git-send-email 2.18.0.219.gaf81d287a9da Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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 --- 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