]> git.ipfire.org Git - thirdparty/git.git/commit
doc: clarify the wording on <git-compat-util.h> requirement
authorJunio C Hamano <gitster@pobox.com>
Mon, 26 Feb 2024 23:28:16 +0000 (15:28 -0800)
committerJunio C Hamano <gitster@pobox.com>
Tue, 27 Feb 2024 16:53:32 +0000 (08:53 -0800)
commit4e89f0e07cfba1155c012728e14f8362ab6a167f
treebcac5168ee920b76aa5252f91f6562d0e1054461
parent0d464a4e6a5a19bd8fbea1deae22d48d14dccb01
doc: clarify the wording on <git-compat-util.h> requirement

The reason why we require the <git-compat-util.h> file to be the
first header file to be included is because it insulates other
header files and source files from platform differences, like which
system header files must be included in what order, and what C
preprocessor feature macros must be defined to trigger certain
features we want out of the system.

We tried to clarify the rule in the coding guidelines document, but
the wording was a bit fuzzy that can lead to misinterpretations like
you can include <xdiff/xinclude.h> only to avoid having to include
<git-compat-util.h> even if you have nothing to do with the xdiff
implementation, for example.  "You do not have to include more than
one of these" was also misleading and would have been puzzling if
you _needed_ to depend on more than one of these approved headers
(answer: you are allowed to include them all if you need the
declarations in them for reasons other than that you want to avoid
including compat-util yourself).

Instead of using the phrase "approved headers", enumerate them as
exceptions, each labeled with its intended audiences, to avoid such
misinterpretations.  The structure also makes it easier to add new
exceptions, so add the description of "t/unit-tests/test-lib.h"
being an exception only for the unit tests implementation as an
example.

Signed-off-by: Junio C Hamano <gitster@pobox.com>
Acked-by: Kyle Lippincott <spectral@google.com>
Acked-by: Elijah Newren <newren@gmail.com>
Documentation/CodingGuidelines