Le mardi 31 mars 2009, Junio C Hamano a écrit : > Christian Couder <chriscool@xxxxxxxxxxxxx> writes: > > I think it's a good thing that you started working on it even if in the > > end we decide that we want these cleanup to be done otherwise. At least > > we will hopefully have clarified our include header policy. > > Before seeing a lot of patches to change #include all over the place, I'd > like to see a simple guiding principle described, not just a subjective > "I think this makes things better" but with "... because of X and Y and > Z". > > The document Documentation/CodingGuidelines describes the only policy > that exists currently: git-compat-util.h must be the first thing the > compiler sees. The language should probably be stronger than what > appears there: > > - The first #include in C files, except in platform specific > compat/ implementations, should be git-compat-util.h or another > well-known header file that includes it at the beginning, namely > cache.h or builtin.h. > > Even though http.h may include "cache.h" at the very beginning, I'd > rather not to see http-walker.c lose inclusion of "cache.h". It will > force us to remember that http.h is Ok to include as the first file, and > that won't scale. > > The reason git-compat-util.h must be the first is because inclusion of > all the system header files is supposed to happen there, and there are > some platforms that have broken system header dependencies we do not want > application writers to care about, and the compat-util header knows about > them. Ok, so I suggest the following simple guiding principles: - git-compat-util.h or cache.h or builtin.h should always be the first #include in C files, - header files should include other incude files if and only if the other includes are needed to compile them, - a header file should be included in a C file only if it is needed to compile the C file (it is not ok to include it only because it includes many other headers that are needed) - other than the above rules, it is ok to reduce the number of includes as much as possible What do you think? By the way, Nathaniel, you should try to give more meaningful titles to the individual patches in your patch series and perhaps make them smaller so that they are easier to review and have less conflicts with other patches. For example your patch "[PATCH 1/5] Header includes cleanup" could be splitted and the resulting patches could be renamed like this "delete includes of 'git-compat-util.h' where 'builtin.h' is included" "delete includes of 'cache.h' where 'builtin.h' is included" "delete includes of 'strbuf.h' where 'builtin.h' is included" "delete includes of 'commit.h' where 'builtin.h' is included" Or perhaps Junio would prefer that you work on a C file by C file basis? Like for example: "delete useless includes in 'builtin-diff-files.c'" "delete useless includes in 'builtin-diff-index.c'" ... Thanks, Christian. -- To unsubscribe from this list: send the line "unsubscribe git" in the body of a message to majordomo@xxxxxxxxxxxxxxx More majordomo info at http://vger.kernel.org/majordomo-info.html