Re: [PATCH 0/9] Add missing includes and forward declares

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Mon, Aug 13, 2018 at 11:24:37AM -0700, Junio C Hamano wrote:

> As things are slowly moving out of the so-far kitchen-sink "cache.h"
> into more specific subsystem headers (like object-store.h), we may
> actually want to tighten the "header that includes it first" part a
> bit in the future, so that 'git grep cache.h' would give us a more
> explicit and a better picture of what really depends on knowing what
> the lowest level plumbing API are built around.

Yeah, I agree that's a good long-term goal. I think "builtin.h" is
reasonable to remain as a magic header for builtins.

> > So I think the better test is a two-line .c file with:
> >
> >   #include "git-compat-util.h"
> >   #include $header_to_check
> 
> But until that tightening happens, I do not actually mind the
> two-line .c file started with inclusion of cache.h instead of
> git-compat-util.h.  That would limit the scope of this series
> further.

I can go either way on this. Using cache.h makes Elijah's current series
a bit more focused. But I think we'd eventually want to go there anyway.
I don't have a strong opinion on doing it now or later.

> > I wonder if there's an easy way to check. I guess adding '-Dint=foo' to
> > the command line, and then putting '#undef int' at the top of
> > git-compat-util would catch just about any code the compiler sees that
> > doesn't have git-compat-util included. :)
> 
> ;-).

So much to my amazement, my off-the-cuff suggestion actually worked
pretty well. The only failures were xdiff (expected, since it does its
own system-header stuff, though IMHO we might think about changing that)
and the programs in t/helper. Here's a patch to address the latter (and
you can see now why I said the above thing about "builtin.h"):

-- >8 --
Subject: [PATCH] test-tool.h: include git-compat-util.h

The test-tool programs include "test-tool.h" as their first
include, which breaks our CodingGuideline of "the first
include must be git-compat-util.h or an equivalent". This
isn't actually a problem, as test-tool.h doesn't define
anything tricky, but we should probably follow our own rule.

Rather than change them all, let's instead make test-tool.h
one of those equivalents, just like we do for builtin.h
(which many of the actual git builtins include first).

Signed-off-by: Jeff King <peff@xxxxxxxx>
---
 t/helper/test-tool.h | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/t/helper/test-tool.h b/t/helper/test-tool.h
index 80cbcf0857..75d7c782f0 100644
--- a/t/helper/test-tool.h
+++ b/t/helper/test-tool.h
@@ -1,6 +1,8 @@
 #ifndef __TEST_TOOL_H__
 #define __TEST_TOOL_H__
 
+#include "git-compat-util.h"
+
 int cmd__chmtime(int argc, const char **argv);
 int cmd__config(int argc, const char **argv);
 int cmd__ctype(int argc, const char **argv);
-- 
2.18.0.1070.g4763fa3c01




[Index of Archives]     [Linux Kernel Development]     [Gcc Help]     [IETF Annouce]     [DCCP]     [Netdev]     [Networking]     [Security]     [V4L]     [Bugtraq]     [Yosemite]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Linux SCSI]     [Fedora Users]

  Powered by Linux