Received: by 2002:a05:6902:102b:0:0:0:0 with SMTP id x11csp3224422ybt; Mon, 22 Jun 2020 19:01:24 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwbnm4wWvo2N28qxM2HlSGC56hR3T3e5N/MIo+Ti6t0thE1cTjBEqspD2KpYbZeDAAvVOKS X-Received: by 2002:a50:afe1:: with SMTP id h88mr15214408edd.295.1592877684201; Mon, 22 Jun 2020 19:01:24 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1592877684; cv=none; d=google.com; s=arc-20160816; b=OMIBO7B4YcaRtWMdMMg5CxiFLfVg+Awxl0XCn8VuzB2sUHSPVGLWxPD30TrafxR13n gyonExFOPx9CGccZQQ7VgpZ8ALcT7FvNrdHr7FclaC5EBrfYYdplcbNBXUnW0L5cmsjK C0O6wbD8B9wRrhqGYI9ZnITOJbiMyr4p06Q+z2JCpixkk4MVHshiQ+8pMbxqS/7kuzB0 Ms3EELakp2SYPjxyBw/DKcoq6yK1TauSiSOIGAeNevc0aesW2vwN7nwIhNa+CXvrmN0/ ZxxM8wok6d5jxJeQGhH/rSF3c2ZxXjeVyYz0IMqGYNFE0eKwKk/5tNafc5XgkNXvOYoA SoPA== 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 :content-language:in-reply-to:mime-version:user-agent:date :message-id:organization:from:references:cc:to:subject:ironport-sdr :ironport-sdr; bh=wJSXpmMRAiHsSHSLZik2A9GM7fHS+UI6134PmOnme0g=; b=C3gSA06OiZHNGAcsE8ock0jU5OVA6vv1brbRERFbPjmgcn2ibm8Ah9rYXwEz9t7c2h ojMBsfr+dC0CmxmU9zRg8Y+ux89yP1qgs286KWPx9cDmjjaJb7iG5mDyRuDVHesUiDBe kjQi9ft6ACNfrBx02mGb2znqZXaSXWhWu6zzc5cBX3ZsSB8Nb2R6/bqZUKk8jhE/JE3o 9cUOt0Pp0WeHHelqhmP1f+zxk7HH9F8gl94bkdvjHGxWjNvPM5pvrfbA2Fv5Qqppm2mh fBd1NBWsrs0WNqbQhNidSkbZUk2L7h5MUm3ehDQ2m24M1IBP+ORAm4+A6yPdNJZAhGta OagQ== 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 f6si11316974edv.356.2020.06.22.19.01.01; Mon, 22 Jun 2020 19:01:24 -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 S1731381AbgFVX4L (ORCPT + 99 others); Mon, 22 Jun 2020 19:56:11 -0400 Received: from mga17.intel.com ([192.55.52.151]:11902 "EHLO mga17.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1730227AbgFVX4K (ORCPT ); Mon, 22 Jun 2020 19:56:10 -0400 IronPort-SDR: cjxSC6Mp8hRHguqrALewvWmUeNON9hFivRi9dBUvx/Ub8o0TEwaTOVvsdEehjx0r4AQiGIMESh RcZTAguKyVYA== X-IronPort-AV: E=McAfee;i="6000,8403,9660"; a="124181112" X-IronPort-AV: E=Sophos;i="5.75,268,1589266800"; d="scan'208";a="124181112" X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from fmsmga003.fm.intel.com ([10.253.24.29]) by fmsmga107.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 22 Jun 2020 16:56:09 -0700 IronPort-SDR: irzyprq6G5p8Nboz85WR7PJ/zywM297w/FBcxuGfnSkwiAz8fhKRvr3cj3fwAc//0h+5khrOiT KBFAiYyYBEkg== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.75,268,1589266800"; d="scan'208";a="318997735" Received: from jekeller-mobl1.amr.corp.intel.com (HELO [10.251.16.129]) ([10.251.16.129]) by FMSMGA003.fm.intel.com with ESMTP; 22 Jun 2020 16:56:08 -0700 Subject: Re: [PATCH] checkpatch: use $root/.git when seeding camel case To: Joe Perches , linux-kernel@vger.kernel.org Cc: Andrew Morton References: <20200622215834.2858106-1-jacob.e.keller@intel.com> From: Jacob Keller Organization: Intel Corporation Message-ID: <66793797-4be2-9c39-edb6-44f731f7c6d6@intel.com> Date: Mon, 22 Jun 2020 16:56:08 -0700 User-Agent: Mozilla/5.0 (Windows NT 10.0; WOW64; rv:68.0) Gecko/20100101 Thunderbird/68.9.0 MIME-Version: 1.0 In-Reply-To: Content-Type: text/plain; charset=utf-8 Content-Language: en-US Content-Transfer-Encoding: 7bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 6/22/2020 3:11 PM, Joe Perches wrote: > On Mon, 2020-06-22 at 14:58 -0700, Jacob Keller wrote: >> 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. > [] >> diff --git 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) { > > checkpatch has 4 uses of ${git_command} > > Maybe git_command should be changed instead. > So, in part, I'm not 100% sure. In our use case, it depends on what git is being used for. Something like "checkpatch.pl -g HEAD", we would like to target the local repository. Where as camelcase, we'd like to target the --root repository. What if, instead of this, we opt to use the local .git for camelcase only when $root is non-empty? That way, if --root is applied, camcel case seeding always uses --root, rather than the local tree. Something like: if (-e ".git" && $root eq "") for this block, so then we fall through to the non-git style instead? > I wonder how this interacts with the GIT_DIR environment variable. > Probably poorly. I suspect it would end up looking at GIT_DIR instead of $root/.git, despite the cd. Thanks, Jake