From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mga03.intel.com (mga03.intel.com [134.134.136.65]) by mx.groups.io with SMTP id smtpd.web12.802.1579220523627003809 for ; Thu, 16 Jan 2020 16:22:03 -0800 Authentication-Results: mx.groups.io; dkim=missing; spf=pass (domain: intel.com, ip: 134.134.136.65, mailfrom: liming.gao@intel.com) X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from orsmga006.jf.intel.com ([10.7.209.51]) by orsmga103.jf.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 16 Jan 2020 16:22:02 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.70,327,1574150400"; d="scan'208";a="226935477" Received: from fmsmsx106.amr.corp.intel.com ([10.18.124.204]) by orsmga006.jf.intel.com with ESMTP; 16 Jan 2020 16:22:02 -0800 Received: from shsmsx606.ccr.corp.intel.com (10.109.6.216) by FMSMSX106.amr.corp.intel.com (10.18.124.204) with Microsoft SMTP Server (TLS) id 14.3.439.0; Thu, 16 Jan 2020 16:22:02 -0800 Received: from shsmsx606.ccr.corp.intel.com (10.109.6.216) by SHSMSX606.ccr.corp.intel.com (10.109.6.216) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.1713.5; Fri, 17 Jan 2020 08:22:00 +0800 Received: from shsmsx606.ccr.corp.intel.com ([10.109.6.216]) by SHSMSX606.ccr.corp.intel.com ([10.109.6.216]) with mapi id 15.01.1713.004; Fri, 17 Jan 2020 08:22:00 +0800 From: "Liming Gao" To: Leif Lindholm , Laszlo Ersek CC: "devel@edk2.groups.io" , "Feng, Bob C" Subject: Re: [PATCH] BaseTools/Conf/gitattributes: fix "--function-context" for *.h and *.c Thread-Topic: [PATCH] BaseTools/Conf/gitattributes: fix "--function-context" for *.h and *.c Thread-Index: AQHVzJ24cWgZtFTaqEiHLAzucUV1HaftT9mAgACurBA= Date: Fri, 17 Jan 2020 00:22:00 +0000 Message-ID: <428016653b214ab699ec2d6b4ecf2fc9@intel.com> References: <20200116184929.18020-1-lersek@redhat.com> <20200116215459.GG20629@bivouac.eciton.net> In-Reply-To: <20200116215459.GG20629@bivouac.eciton.net> Accept-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: x-originating-ip: [10.239.127.36] MIME-Version: 1.0 Return-Path: liming.gao@intel.com Content-Language: en-US Content-Type: text/plain; charset="iso-2022-jp" Content-Transfer-Encoding: quoted-printable Leif: Vfr is not C style source file. It can't be regarded as C source file.=20 Laszlo: Is there such support for the assembly file, such as .nasm? Thanks Liming -----Original Message----- From: Leif Lindholm =20 Sent: 2020=1B$BG/=1B(B1=1B$B7n=1B(B17=1B$BF|=1B(B 5:55 To: Laszlo Ersek Cc: devel@edk2.groups.io; Feng, Bob C ; Gao, Liming <= liming.gao@intel.com> Subject: Re: [PATCH] BaseTools/Conf/gitattributes: fix "--function-context"= for *.h and *.c On Thu, Jan 16, 2020 at 19:49:29 +0100, Laszlo Ersek wrote: > The "--function-context" ("-W") option of git-diff displays the entire=20 > body of a modified function, not just small modified hunks within the=20 > function. It is useful for reviewers when the code changes to the=20 > function are small, but they could affect, or depend on, control flow=20 > that is far away in the same function. >=20 > Of course, the size of the displayed context can be controlled with=20 > the "-U" option anyway, but such fixed-size contexts are usually=20 > either too small, or too large, in the above scenario. >=20 > It turns out that "--function-context" does not work correctly for *.h=20 > and *.c files in edk2. In particular, labels for the goto instruction=20 > (which the edk2 coding style places in the leftmost column) appear to=20 > terminate "--function-context". >=20 > The "git" utility contains built-in hunk header patterns for the C and=20 > C++ languages. However, they do not take effect in edk2 because we=20 > don't explicitly assign the "cpp" git-diff driver to our *.h and *.c=20 > files. The > gitattributes(5) manual explains that this is required: >=20 > > There are a few built-in patterns to make this easier, and > > tex is one of them, so you do not have to write the above in > > your configuration file (you still need to enable this with > > the attribute mechanism, via .gitattributes). The following > > built in patterns are available: > > > > [...] > > > > * cpp suitable for source code in the C and C++ > > languages. >=20 > The key statement is the one in parentheses. >=20 > Thus, mark our *.h and *.c files as belonging to the "cpp" git-diff=20 > driver. >=20 > This change has a dramatic effect on the following command, for example: >=20 > $ git show -W 2ef0c27cb84c This looks really good, I didn't realise we weren't actually using properly= C-aware diff by default. And thank you for the perfect level of background= . However, if doing this change, would we want to apply it to all source code= types supported by BaseTools (i.e. referenced in build_rule.template)? That would mean: .c .cc .C .CC .cpp .Cpp .CPP .h .H and possibly .act .aslc .vfr .Vfr .VFR / Leif >=20 > Cc: Bob Feng > Cc: Leif Lindholm > Cc: Liming Gao > Signed-off-by: Laszlo Ersek > --- > BaseTools/Conf/gitattributes | 2 ++ > 1 file changed, 2 insertions(+) >=20 > diff --git a/BaseTools/Conf/gitattributes=20 > b/BaseTools/Conf/gitattributes index 58b93e9d4c27..8b8b4b92105b 100644 > --- a/BaseTools/Conf/gitattributes > +++ b/BaseTools/Conf/gitattributes > @@ -17,3 +17,5 @@ > *.fdf diff=3Dini > *.fdf.inc diff=3Dini > *.inf diff=3Dini > +*.h diff=3Dcpp > +*.c diff=3Dcpp > -- > 2.19.1.3.g30247aa5d201 >=20