audk/BaseTools/Conf
Laszlo Ersek eafd990f26 BaseTools/Conf/gitattributes: fix "--function-context" for C source code
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 2ef0c27cb8

Cc: Bob Feng <bob.c.feng@intel.com>
Cc: Leif Lindholm <leif.lindholm@linaro.org>
Cc: Liming Gao <liming.gao@intel.com>
Signed-off-by: Laszlo Ersek <lersek@redhat.com>
Message-Id: <20200120094245.9010-1-lersek@redhat.com>
Reviewed-by: Leif Lindholm <leif@nuviainc.com>
Reviewed-by: Leif Lindholm <leif.lindholm@linaro.org>
Reviewed-by: Liming Gao <liming.gao@intel.com>
2020-01-31 16:13:06 +00:00
..
XMLSchema BaseTools: Fix various typos 2019-07-08 08:59:29 +08:00
Empty_Package_Information_Data_File.ini BaseTools: Replace BSD License with BSD+Patent License 2019-04-09 09:10:20 -07:00
ReadMe.txt BaseTools: Clean up source files 2018-07-09 10:25:47 +08:00
build_rule.template BaseTools: Update build_rule.txt to generate dependent files. 2019-12-10 01:31:55 +00:00
diff.order BaseTools: fix line endings in SetupGit.py Conf files 2019-10-04 11:18:22 +01:00
gitattributes BaseTools/Conf/gitattributes: fix "--function-context" for C source code 2020-01-31 16:13:06 +00:00
target.template BaseTools: Update Conf/target.template with the default EmulatorPkg.dsc 2019-05-23 22:40:29 +08:00
tools_def.template BaseTools:replaces the two offending quotes by ascii quotes 2019-12-18 01:57:24 +00:00

ReadMe.txt

This file contains invisible Unicode characters

This file contains invisible Unicode characters that are indistinguishable to humans but may be processed differently by a computer. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

This directory contains the template files for the next generation of the
EDK II Build infrastructure.  These files will be copied into the WORKSPACE's
Conf directory if and only if the target files do not exist.

These files may be updated frequently.

The XMLSchema directory contains the EDK II Packaging XML definitions.  The
schema may change in the future.  It differs somewhat from the early versions
of the XML Schema.