Received: by 2002:a05:6902:102b:0:0:0:0 with SMTP id x11csp3094287ybt; Mon, 22 Jun 2020 15:01:02 -0700 (PDT) X-Google-Smtp-Source: ABdhPJx5yH1tKFMSp/AxQXZfVfh/X+JHKUh3zGD70jlZyEC9dJeSBoNrbPJ9A268CP7BGHHctqyn X-Received: by 2002:a17:906:4f16:: with SMTP id t22mr464257eju.179.1592863261920; Mon, 22 Jun 2020 15:01:01 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1592863261; cv=none; d=google.com; s=arc-20160816; b=fBp1YxqnZ86bFYF3/6yQy0xqzoJCa9sCVkMK5mY/rRkJ5ivGzsPjpxRIvRuyhf7p5Q dwDxAZcpazjUr7VuMEVTtlUvEenOQq779SOjXRcERLP2hQSa6oQidho6Mqz41ysbxfxc HUqp7Co92hn/im9IN0zxabaZrhse1PqYxmclwlLd0UjPMrATq5G95mpBv0ogtEm+CpfD EF3KZgtG09c2Nh6f1vfAMbt/vxvNr1NCcfgTkjeFmRqB+XuQAbGCzLm59QF7WI208VPO 14Md8wKcfHCCYMVdWO1gK1TkgyfHrh5N2ylOBGRjmcJUVsCvpqrFrN3BFOI4evj2FIC4 /cWQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :message-id:date:subject:cc:to:from:ironport-sdr:ironport-sdr; bh=QW8jkDdCKhcbcR/b9aZsDbXv2l2KTm46zE8ld+UQ8Es=; b=BBwkisEzB6srozOltP6Dta6/r/eceD9HuVBbXMmKipDDgMRpMRgs4CWB3FADSN0ssP 9hirUJXpqPDlJIMHoJgqGlX6qwJ0wRoBPVafNyI5uW0HZY9/qypSZ4sackT2ur74mWeF /2duVwn6eyC2slOxgOQDyRsgKKGallR2VPF9TDfEPvi+XgRTePWY8S4wdjkwIoWWRt6G 2zR9xn4EBTuSI6aLKAmezBkw0zN6yRBluBT7uDsI/roSHeEUWfdZqEGdKNVLMKR5JXda 86J9CpEGGB+JKWeV9Fj6VEBiTsFyzuva7vt/MGdOrVMUU+PWcmGmA89YaKQiO31DhO1k N4OA== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 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. [23.128.96.18]) by mx.google.com with ESMTP id m27si1981065edj.431.2020.06.22.15.00.39; Mon, 22 Jun 2020 15:01:01 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 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 S1730940AbgFVV6m (ORCPT + 99 others); Mon, 22 Jun 2020 17:58:42 -0400 Received: from mga12.intel.com ([192.55.52.136]:5659 "EHLO mga12.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1730930AbgFVV6j (ORCPT ); Mon, 22 Jun 2020 17:58:39 -0400 IronPort-SDR: oFhWc1wJXvfzxzHSMsKAbAQjza5eaQQ1ecoKplYpgSScsC8PGLq/1Hgdy6mUETAcdxpoiDVID+ 45SNCGdAf7FA== X-IronPort-AV: E=McAfee;i="6000,8403,9660"; a="123554287" X-IronPort-AV: E=Sophos;i="5.75,268,1589266800"; d="scan'208";a="123554287" X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from orsmga001.jf.intel.com ([10.7.209.18]) by fmsmga106.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 22 Jun 2020 14:58:36 -0700 IronPort-SDR: fB/8J8qmlJt3Mr8TDqDQuuvyalAq2ZmOkiO7NhpiF3bDkTPLf6lQM1x6Qd4gxfwwatzPe8zc2A oSsBIiFzpoAQ== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.75,268,1589266800"; d="scan'208";a="353605289" Received: from jekeller-desk.amr.corp.intel.com ([10.166.241.33]) by orsmga001.jf.intel.com with ESMTP; 22 Jun 2020 14:58:36 -0700 From: Jacob Keller To: linux-kernel@vger.kernel.org Cc: Jacob Keller , Joe Perches Subject: [PATCH] checkpatch: use $root/.git when seeding camel case Date: Mon, 22 Jun 2020 14:58:34 -0700 Message-Id: <20200622215834.2858106-1-jacob.e.keller@intel.com> X-Mailer: git-send-email 2.25.2 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org When seeding the camel case file, checkpatch.pl uses the $root directory in order to find the acceptable list of allowed camel case words. However, if the current directory is a git repository, checkpatch.pl attempts to seed using the local git directory. This is problematic if checkpatch.pl is passed a --root and is being run from within another git repository. Rather than seeding from the provided root tree, checkpatch.pl will seed using the local files. If the current git repository isn't a kernel tree, this can lead to unexpected warnings about camel case issues. Always honor the $root parameter when seeding camelcase files by using "$root/.git" and changing directory to the $root before invoking git. Signed-off-by: Jacob Keller Cc: Joe Perches --- This is a resend of an old patch that appears to have never been picked up. It was originally reviewed at the following locations a few years ago: https://patchwork.ozlabs.org/project/intel-wired-lan/patch/20160505231108.1934-1-jacob.e.keller@intel.com/ https://lore.kernel.org/netdev/20190315010334.5707-1-jacob.e.keller@intel.com/ The motivation is that we use checkpatch.pl on code in a separate git repository that will eventually be submitted upstream. As part of this, we provide the --root argument to specify the target kernel tree. The camelcase then gets seeded incorrectly and --strict begins warning about a lot of cases that aren't errors. The current workaround is that we cd to the kernel tree and run checkpatch from there.. but this breaks if we want to use a .checkpatch.conf file as it won't get picked up from the original directory. This patch simply fixes the camelcase seeding to honor the git tree at the $root if one is provided. I opted to stick with "cd $root &&" instead of "git -C", since there are no other usages of "git -C" in the checkpatch.pl currently, despite "git -C" being from git 1.8.5, and being ~7 years old. scripts/checkpatch.pl | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/scripts/checkpatch.pl b/scripts/checkpatch.pl index 4c820607540b..c5646e456325 100755 --- a/scripts/checkpatch.pl +++ b/scripts/checkpatch.pl @@ -919,8 +919,8 @@ sub seed_camelcase_includes { $camelcase_seeded = 1; - if (-e ".git") { - my $git_last_include_commit = `${git_command} log --no-merges --pretty=format:"%h%n" -1 -- include`; + if (-e "$root/.git") { + my $git_last_include_commit = `cd $root && ${git_command} log --no-merges --pretty=format:"%h%n" -1 -- include`; chomp $git_last_include_commit; $camelcase_cache = ".checkpatch-camelcase.git.$git_last_include_commit"; } else { @@ -947,9 +947,10 @@ sub seed_camelcase_includes { return; } - if (-e ".git") { - $files = `${git_command} ls-files "include/*.h"`; + if (-e "$root/.git") { + $files = `cd $root && ${git_command} ls-files "include/*.h"`; @include_files = split('\n', $files); + @include_files = map("$root/$_", @include_files); } foreach my $file (@include_files) { -- 2.25.2