From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mail-wm1-f68.google.com (mail-wm1-f68.google.com [209.85.128.68]) by mx.groups.io with SMTP id smtpd.web11.1527.1579222265739526962 for ; Thu, 16 Jan 2020 16:51:06 -0800 Authentication-Results: mx.groups.io; dkim=pass header.i=@linaro.org header.s=google header.b=f7Wl1xFT; spf=pass (domain: linaro.org, ip: 209.85.128.68, mailfrom: leif.lindholm@linaro.org) Received: by mail-wm1-f68.google.com with SMTP id p17so5838590wma.1 for ; Thu, 16 Jan 2020 16:51:05 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=date:from:to:cc:subject:message-id:references:mime-version :content-disposition:content-transfer-encoding:in-reply-to :user-agent; bh=vWkawi1W9/ehJqRJtJidVsqr0Bk06VNNsELKNnyXZvA=; b=f7Wl1xFT+m6j+U0N2p3ORZkoliL2K8TfSvH8z7EdGChClFAya/L674OOtwGxyXEfUx I0odNHMoZ1qOLq4XVP7Uf3UjU8x6qCouncF0pRU0vhIOfGF483Y/iwOMABMdhiEEKMyv uy8Ff9erW5zRH4woFbj73IOcuzg00A9Hk3CUxipKzJQAl/X8hvmMehkurisMbePNBgJl RFWMY7T4tK2/rzGmt6p/DXbLT6VZT6fsYk7qMfW7YbHCK6CyyCL5NUfNzka6VKwWXefh K32Ya0UpvUz/sKntwvUC6JZXZ0AbF1qfUeNk9NBIz99/Xyi3uBRAa7sWlX/IIWlUmxDI N0uQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-disposition:content-transfer-encoding :in-reply-to:user-agent; bh=vWkawi1W9/ehJqRJtJidVsqr0Bk06VNNsELKNnyXZvA=; b=lYqPTbWjfhQMp5A4YjZk2kFU36Zcgt72EWMZkyLjnR37Qbm0INYryZUooc22XFl0nf iTm43u8mQ07O/yblum4spLyLux6AMd5fmcbT2HBjBZTMqMHOKXrWy4mZ2iyuqJK4F6Gb nVoY8+YYp/mQNtJo/RJgmf4k688fvl2JEgKbd9GpMw3zzPkzfPeivxOYfGPeoZ9ak6Ga 2nx3lic8YZaavJHYtsMPvK0fwWTeCiBomP/YDNzJRS3LGcxq6lHyQ38TlnqFNsVyWqQB pqWfjsYozUQ+sNOG6aYURl7maRNg3k2SQvsI7NUckHRkL2UCo7+Eg/Vz4X5envnXJV+a ydYQ== X-Gm-Message-State: APjAAAXUdCzUiRZ0a72JFsL1hHyMiSpZfb7VqhKyKaGDxzbeUmLrPL8D J2fiR9QntzdaxHOZqWH+ty1nWQ== X-Google-Smtp-Source: APXvYqwVG3PVvPuEviKwVwwx9bAeDjrQLpK3D8JubEjrT5VY/gnPE6vOjwmRQuFn29oXHkIbfyWSAA== X-Received: by 2002:a1c:5444:: with SMTP id p4mr1782705wmi.33.1579222264327; Thu, 16 Jan 2020 16:51:04 -0800 (PST) Return-Path: Received: from bivouac.eciton.net (bivouac.eciton.net. [2a00:1098:0:86:1000:23:0:2]) by smtp.gmail.com with ESMTPSA id x10sm30866578wrv.60.2020.01.16.16.51.03 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 16 Jan 2020 16:51:03 -0800 (PST) Date: Fri, 17 Jan 2020 00:51:02 +0000 From: Leif Lindholm To: "Gao, Liming" Cc: Laszlo Ersek , "devel@edk2.groups.io" , "Feng, Bob C" Subject: Re: [PATCH] BaseTools/Conf/gitattributes: fix "--function-context" for *.h and *.c Message-ID: <20200117005102.GJ20629@bivouac.eciton.net> References: <20200116184929.18020-1-lersek@redhat.com> <20200116215459.GG20629@bivouac.eciton.net> <428016653b214ab699ec2d6b4ecf2fc9@intel.com> MIME-Version: 1.0 In-Reply-To: <428016653b214ab699ec2d6b4ecf2fc9@intel.com> User-Agent: Mutt/1.10.1 (2018-07-13) Content-Type: text/plain; charset=utf-8 Content-Disposition: inline Content-Transfer-Encoding: 8bit Liming, Hence the "possibly" :) Although, I agree, grouping it with .aslc (which definitely *is* C), was a bit confusing. I couldn't actually find any .act in the tree - are those obsolete, or do we simply not have any in the tree? (If the latter, should we add something in order to support simple build tests?) Regards, Leif On Fri, Jan 17, 2020 at 00:22:00 +0000, Gao, Liming wrote: > Leif: > Vfr is not C style source file. It can't be regarded as C source file. > > Laszlo: > Is there such support for the assembly file, such as .nasm? > > Thanks > Liming > -----Original Message----- > From: Leif Lindholm > Sent: 2020年1月17日 5:55 > To: Laszlo Ersek > Cc: devel@edk2.groups.io; Feng, Bob C ; Gao, Liming > 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 > > body of a modified function, not just small modified hunks within the > > function. It is useful for reviewers when the code changes to the > > function are small, but they could affect, or depend on, control flow > > that is far away in the same function. > > > > Of course, the size of the displayed context can be controlled with > > the "-U" option anyway, but such fixed-size contexts are usually > > either too small, or too large, in the above scenario. > > > > It turns out that "--function-context" does not work correctly for *.h > > and *.c files in edk2. In particular, labels for the goto instruction > > (which the edk2 coding style places in the leftmost column) appear to > > terminate "--function-context". > > > > The "git" utility contains built-in hunk header patterns for the C and > > C++ languages. However, they do not take effect in edk2 because we > > don't explicitly assign the "cpp" git-diff driver to our *.h and *.c > > files. The > > gitattributes(5) manual explains that this is required: > > > > > 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. > > > > The key statement is the one in parentheses. > > > > Thus, mark our *.h and *.c files as belonging to the "cpp" git-diff > > driver. > > > > This change has a dramatic effect on the following command, for example: > > > > $ 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 > > > > > Cc: Bob Feng > > Cc: Leif Lindholm > > Cc: Liming Gao > > Signed-off-by: Laszlo Ersek > > --- > > BaseTools/Conf/gitattributes | 2 ++ > > 1 file changed, 2 insertions(+) > > > > diff --git a/BaseTools/Conf/gitattributes > > b/BaseTools/Conf/gitattributes index 58b93e9d4c27..8b8b4b92105b 100644 > > --- a/BaseTools/Conf/gitattributes > > +++ b/BaseTools/Conf/gitattributes > > @@ -17,3 +17,5 @@ > > *.fdf diff=ini > > *.fdf.inc diff=ini > > *.inf diff=ini > > +*.h diff=cpp > > +*.c diff=cpp > > -- > > 2.19.1.3.g30247aa5d201 > >