From nobody Fri May 3 20:36:35 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of groups.io designates 66.175.222.12 as permitted sender) client-ip=66.175.222.12; envelope-from=bounce+27952+53312+1787277+3901457@groups.io; helo=web01.groups.io; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of groups.io designates 66.175.222.12 as permitted sender) smtp.mailfrom=bounce+27952+53312+1787277+3901457@groups.io; dmarc=fail(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1579200581; cv=none; d=zohomail.com; s=zohoarc; b=WJFViW0B6frX89fidqboN+1UzNwtleJ4ZzllnSh9gpslnhwJSlvvUI1nWsg7w2pSnhZcE0bnzX3ph4LnpuSLS7RkA6K1c5NTm4upgg1mT2pfH6o+dsW2ijntRW/FeIS5I8TV8zulwqv4XDT2wtuD3yPpmdrGTdcWVunPD/dxyi0= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1579200581; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:List-Id:List-Unsubscribe:MIME-Version:Message-ID:Reply-To:Sender:Subject:To; bh=+3Q4WJ4N1g48Z8bo01EJm7U+FjP3DxFYqgbGsferaF8=; b=aL9wiT1fMC6NDguG2zV/CwamHxx7JfnPTJGARYOVUI419Cl5bkeVNxiwaBYRcKyVbwUhMFyuYsNaFr/Ef3wRnJ/5KX9HBB6HnRSuFBP6bX/s7//3yfL4jbhy1S5z9PBGgBbc1BJZkr8ehXfQLQdoA5BPmHZAKHgUGiSJNumEzAk= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of groups.io designates 66.175.222.12 as permitted sender) smtp.mailfrom=bounce+27952+53312+1787277+3901457@groups.io; dmarc=fail header.from= (p=none dis=none) header.from= Received: from web01.groups.io (web01.groups.io [66.175.222.12]) by mx.zohomail.com with SMTPS id 1579200581252258.14877493883046; Thu, 16 Jan 2020 10:49:41 -0800 (PST) Return-Path: X-Received: by 127.0.0.2 with SMTP id NhigYY1788612x1JE2LF8d8Y; Thu, 16 Jan 2020 10:49:40 -0800 X-Received: from us-smtp-1.mimecast.com (us-smtp-1.mimecast.com [207.211.31.81]) by mx.groups.io with SMTP id smtpd.web09.1172.1579200580064656613 for ; Thu, 16 Jan 2020 10:49:40 -0800 X-Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-15-9d1lrD8_OxCy-gt2O1DjrA-1; Thu, 16 Jan 2020 13:49:33 -0500 X-Received: from smtp.corp.redhat.com (int-mx06.intmail.prod.int.phx2.redhat.com [10.5.11.16]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 6F60C8017CC; Thu, 16 Jan 2020 18:49:32 +0000 (UTC) X-Received: from lacos-laptop-7.usersys.redhat.com (ovpn-116-120.ams2.redhat.com [10.36.116.120]) by smtp.corp.redhat.com (Postfix) with ESMTP id 465BA5C241; Thu, 16 Jan 2020 18:49:31 +0000 (UTC) From: "Laszlo Ersek" To: devel@edk2.groups.io Cc: Bob Feng , Leif Lindholm , Liming Gao Subject: [edk2-devel] [PATCH] BaseTools/Conf/gitattributes: fix "--function-context" for *.h and *.c Date: Thu, 16 Jan 2020 19:49:29 +0100 Message-Id: <20200116184929.18020-1-lersek@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.16 X-MC-Unique: 9d1lrD8_OxCy-gt2O1DjrA-1 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Precedence: Bulk List-Unsubscribe: Sender: devel@edk2.groups.io List-Id: Mailing-List: list devel@edk2.groups.io; contact devel+owner@edk2.groups.io Reply-To: devel@edk2.groups.io,lersek@redhat.com X-Gm-Message-State: tFpDpGgQGtYrX4tYPymdDy4Lx1787277AA= Content-Transfer-Encoding: quoted-printable DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=groups.io; q=dns/txt; s=20140610; t=1579200580; bh=+3Q4WJ4N1g48Z8bo01EJm7U+FjP3DxFYqgbGsferaF8=; h=Cc:Content-Type:Date:From:Reply-To:Subject:To; b=oLgbqGsc8B8/5I9CQo1DN0hZrOoIY73H0UCWrKrL3nKQy2K1XSii/kpY79/YaJl6ED8 OdSLrJqR7fD9tg7r8l1n6AEYmb92digRvyxLPYtv2ewhIRfOHzKAeJogJxswjtVA1T4vp 4lx4q+lPScGtajW7iz4YzOEb3tWvA884JR4= X-ZohoMail-DKIM: pass (identity @groups.io) Content-Type: text/plain; charset="utf-8" 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 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=3Dini *.fdf.inc diff=3Dini *.inf diff=3Dini +*.h diff=3Dcpp +*.c diff=3Dcpp --=20 2.19.1.3.g30247aa5d201 -=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D- Groups.io Links: You receive all messages sent to this group. View/Reply Online (#53312): https://edk2.groups.io/g/devel/message/53312 Mute This Topic: https://groups.io/mt/69751918/1787277 Group Owner: devel+owner@edk2.groups.io Unsubscribe: https://edk2.groups.io/g/devel/unsub [importer@patchew.org] -=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-