From nobody Mon May 6 18:33:00 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+53398+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+53398+1787277+3901457@groups.io; dmarc=fail(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1579513375; cv=none; d=zohomail.com; s=zohoarc; b=eUsLPzS8FCJ9KiEgxl4CBqsQVscWn5Dey2kVpmmE2EJEIt1muNiiN6lFNZXMFCxRIKI+mPODH1az01nM+KRKocvZMvI41rLFY+ooMMOoNfbvknwLqnEH4M7n/+sIHiDri3DWEuTUrBfHQvIzyio9KHrdlI3amV02a+LBlM0CaHE= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1579513375; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:List-Id:List-Unsubscribe:MIME-Version:Message-ID:Reply-To:Sender:Subject:To; bh=tTz0rJbjcMH6wDNRlxEM5//nASB8rs7U5/I2lhE4gYw=; b=LPvwmwyplL32ytBR0gvf4CivnkLSB//VK0YfpY4yUKeXoXfkGIx1aApaMNmKVkRkRZ+zQ3s6yl9YclxTzbJPJXu+jeM501k+7MD1nuOhYuSShOySDdnT5gC4sYm9QkD3qWA6LgQ5Fw5UddKYo2/xHU0PzTIhxhkxzwxUw7TSeg8= 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+53398+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 1579513375516887.0871691985312; Mon, 20 Jan 2020 01:42:55 -0800 (PST) Return-Path: X-Received: by 127.0.0.2 with SMTP id Ug7WYY1788612x4D9IGZnNyP; Mon, 20 Jan 2020 01:42:54 -0800 X-Received: from us-smtp-1.mimecast.com (us-smtp-1.mimecast.com [207.211.31.120]) by mx.groups.io with SMTP id smtpd.web11.8425.1579513374114476125 for ; Mon, 20 Jan 2020 01:42:54 -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-357-pPtVtk_OPTODrr8EMSq8gg-1; Mon, 20 Jan 2020 04:42:50 -0500 X-Received: from smtp.corp.redhat.com (int-mx03.intmail.prod.int.phx2.redhat.com [10.5.11.13]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 9FFBE18B5FA5; Mon, 20 Jan 2020 09:42:48 +0000 (UTC) X-Received: from lacos-laptop-7.usersys.redhat.com (ovpn-117-50.ams2.redhat.com [10.36.117.50]) by smtp.corp.redhat.com (Postfix) with ESMTP id 3EA3D48; Mon, 20 Jan 2020 09:42:47 +0000 (UTC) From: "Laszlo Ersek" To: edk2-devel-groups-io Cc: Bob Feng , Leif Lindholm , Liming Gao Subject: [edk2-devel] [PATCH v2] BaseTools/Conf/gitattributes: fix "--function-context" for C source code Date: Mon, 20 Jan 2020 10:42:45 +0100 Message-Id: <20200120094245.9010-1-lersek@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.13 X-MC-Unique: pPtVtk_OPTODrr8EMSq8gg-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: LSyJrjnJTsxpp5xgh53ciaGYx1787277AA= Content-Transfer-Encoding: quoted-printable DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=groups.io; q=dns/txt; s=20140610; t=1579513374; bh=tTz0rJbjcMH6wDNRlxEM5//nASB8rs7U5/I2lhE4gYw=; h=Cc:Content-Type:Date:From:Reply-To:Subject:To; b=fwgSWqea0Wd+uO3VInQiq3vQFTMh8EiTWvWPFBte134qrWkrNcKRBdnhRYmI/3C2L66 hjTL7L5ys0qp3CzAyZRQnN3Y2h09zRYZMhTqO0W+vh9n5k/3EANkXw/Ua1mJWcbD9+xWo 7znTq63fU92CFcGLH/T878Jt+RsweAyhy4s= 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 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 Reviewed-by: Leif Lindholm --- Notes: v2: =20 - take suffixes from "BaseTools/Conf/build_rule.template" [Leif] =20 - replace "*.h" / "*.c" in the commit message with "C source" and [C-Code-File] / [Acpi-Table-Code-File] =20 - 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=3Dini *.fdf.inc diff=3Dini *.inf diff=3Dini +*.c diff=3Dcpp +*.C diff=3Dcpp +*.cc diff=3Dcpp +*.CC diff=3Dcpp +*.cpp diff=3Dcpp +*.Cpp diff=3Dcpp +*.CPP diff=3Dcpp +*.aslc diff=3Dcpp +*.act diff=3Dcpp +*.h diff=3Dcpp +*.H 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 (#53398): https://edk2.groups.io/g/devel/message/53398 Mute This Topic: https://groups.io/mt/69928741/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-