From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mail-wr1-f65.google.com (mail-wr1-f65.google.com [209.85.221.65]) by mx.groups.io with SMTP id smtpd.web11.8664.1579515134301440326 for ; Mon, 20 Jan 2020 02:12:14 -0800 Authentication-Results: mx.groups.io; dkim=pass header.i=@nuviainc-com.20150623.gappssmtp.com header.s=20150623 header.b=Cedqk0X+; spf=pass (domain: nuviainc.com, ip: 209.85.221.65, mailfrom: leif@nuviainc.com) Received: by mail-wr1-f65.google.com with SMTP id w15so28926123wru.4 for ; Mon, 20 Jan 2020 02:12:14 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=nuviainc-com.20150623.gappssmtp.com; s=20150623; h=date:from:to:cc:subject:message-id:references:mime-version :content-disposition:in-reply-to:user-agent; bh=TPsE+N0UWhGrA2g4XPYqrGPZoLSeC8Ms5DbUjE3M9l0=; b=Cedqk0X+Lh7ibSKJjtEDv/VVOmWvBlsa/7NW5MUrN4f7pwvZVjfHIc9J5Q8gKskAla 9Ib6qhGnkUJL5Ta5KuHbEZ6Z240PUZsU+P6eLVe4UoSBPzz/gRjBe1FwctI5N4lcstOZ OpYR1AAKOVjdD7NwdzGUjdcFnRIKi4ItI9PgYxUz+jOl6uOI//ydPaY1q2gdpcSFqo1K +ZpKrJWSKgVRjPDn/RqJaui2RvjYEi6iOh+74DzB2HOSzHPPhYV0lfJijgTfiZlAUVb0 fL+2ilUfNDBT+ox8EHvN6cnrDxKcbWCYDX98ZtMBWSgvDyOUCOBKZQq4jnGfdWQKMs+4 An6Q== 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:in-reply-to:user-agent; bh=TPsE+N0UWhGrA2g4XPYqrGPZoLSeC8Ms5DbUjE3M9l0=; b=RKzpLPSHLOOQA8IL+tl7KRYQ9v8E2At86i5x8K2R9y6+UDS41OD7/rebhuf7soPMVB 3shIH/Ouqcfh7WencaIc7LljvovrKyhA6V9Y1fDf9Jio9MXEYmgnQy4z1t9GHiki3Q5W vIHSTthEO31QGcCCia24dM9u+H8jRwhbQBe9pfE8/gxWv3Qa/svIM7cgVWVtp6DPBXpx hS/9zXXD5kuPyg8Q8giNsLvdWQXOebhDLC0DJ0lQkXXgY4X5bYge7TqCsMToVbDr6n1a epH/xB3ZPm830m0N93vu/q5hqTlQnK2Jgcn0r799EBoxOT9wswVlabIp/Bp0q9+RL9+V oE/A== X-Gm-Message-State: APjAAAVY4j2uQ/BCGUbqNsE6vRnOpciW8Cr5EFPgkcTnogq7npgLQCr5 jMxDLIRcVk9U5gGKh/SJO/guqaUq9pUk0IkoeScPIb2ZagZ0kmDA7vvNpXbvEk3S/TbsmJxbfaZ QGmZNFVefkwxWL8GcKvZXhbBTvnBPbPg+UvrT5emq6+ZJBjxKNub5Us8yn3Rx7bM= X-Google-Smtp-Source: APXvYqwMJ/Uz3BLu6wdlTu5qeVyrKhEzriCRIYTX5q4TGJCYw6C6tUy3P/6o7OIcHWEZfaXquirMOA== X-Received: by 2002:adf:a308:: with SMTP id c8mr16673347wrb.240.1579515132566; Mon, 20 Jan 2020 02:12:12 -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 y6sm45562745wrl.17.2020.01.20.02.12.11 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 20 Jan 2020 02:12:12 -0800 (PST) Date: Mon, 20 Jan 2020 10:12:10 +0000 From: "Leif Lindholm" To: devel@edk2.groups.io, lersek@redhat.com Cc: Bob Feng , Liming Gao Subject: Re: [edk2-devel] [PATCH v2] BaseTools/Conf/gitattributes: fix "--function-context" for C source code Message-ID: <20200120101210.GR15141@bivouac.eciton.net> References: <20200120094245.9010-1-lersek@redhat.com> MIME-Version: 1.0 In-Reply-To: <20200120094245.9010-1-lersek@redhat.com> User-Agent: Mutt/1.10.1 (2018-07-13) Content-Type: text/plain; charset=us-ascii Content-Disposition: inline On Mon, Jan 20, 2020 at 10:42:45 +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 C > source 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 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. > > Grab the suffix lists from the [C-Code-File] and [Acpi-Table-Code-File] > sections of "BaseTools/Conf/build_rule.template", add "*.h" and "*.H", and > mark those as belonging to the "cpp" git-diff driver. > > This change has a dramatic effect on the following command, for example: > > $ git show -W 2ef0c27cb84c > > Cc: Bob Feng > Cc: Leif Lindholm > Cc: Liming Gao > Signed-off-by: Laszlo Ersek Reviewed-by: Leif Lindholm also Reviewed-by: Leif Lindholm (if it jars too much to use a different one from Cc: tag above) For other purposes, the Linaro address can now be considered retired. / Leif > --- > > Notes: > v2: > > - take suffixes from "BaseTools/Conf/build_rule.template" [Leif] > > - replace "*.h" / "*.c" in the commit message with "C source" and > [C-Code-File] / [Acpi-Table-Code-File] > > - Supersedes: <20200116184929.18020-1-lersek@redhat.com> > http://mid.mail-archive.com/20200116184929.18020-1-lersek@redhat.com > https://edk2.groups.io/g/devel/message/53312 > > BaseTools/Conf/gitattributes | 11 +++++++++++ > 1 file changed, 11 insertions(+) > > diff --git a/BaseTools/Conf/gitattributes b/BaseTools/Conf/gitattributes > index 58b93e9d4c27..319e89064133 100644 > --- a/BaseTools/Conf/gitattributes > +++ b/BaseTools/Conf/gitattributes > @@ -17,3 +17,14 @@ > *.fdf diff=ini > *.fdf.inc diff=ini > *.inf diff=ini > +*.c diff=cpp > +*.C diff=cpp > +*.cc diff=cpp > +*.CC diff=cpp > +*.cpp diff=cpp > +*.Cpp diff=cpp > +*.CPP diff=cpp > +*.aslc diff=cpp > +*.act diff=cpp > +*.h diff=cpp > +*.H diff=cpp > -- > 2.19.1.3.g30247aa5d201 > > > >