[PATCH v3 2/2] headers: include dependent headers
Add dependent headers so that including a header does not require including additional headers. This makes it so that gcc -c $header succeeds for each header. Helped-by: René Scharfe l@web.de Signed-off-by: David Aguilar dav...@gmail.com --- Replacement patch with René's suggestions squashed in. archive.h| 1 + argv-array.h | 2 ++ attr.h | 2 ++ branch.h | 2 ++ builtin.h| 1 - cache-tree.h | 1 + cache.h | 1 - color.h | 3 ++- column.h | 2 ++ commit.h | 2 +- compat/bswap.h | 7 +++ compat/precompose_utf8.h | 8 +++- convert.h| 3 +++ credential.h | 1 + csum-file.h | 2 ++ delta.h | 2 ++ diff.h | 2 +- diffcore.h | 2 ++ dir.h| 3 ++- ewah/ewok.h | 2 ++ ewah/ewok_rlw.h | 2 ++ exec_cmd.h | 2 ++ fsck.h | 2 ++ gpg-interface.h | 2 ++ graph.h | 2 ++ hashmap.h| 2 ++ help.h | 2 ++ khash.h | 2 ++ kwset.h | 2 ++ line-log.h | 1 + list-objects.h | 2 ++ ll-merge.h | 2 ++ mailmap.h| 3 +++ merge-recursive.h| 2 ++ notes-cache.h| 1 + notes-merge.h| 3 +++ notes-utils.h| 1 + notes.h | 1 + object.h | 2 ++ pack-bitmap.h| 2 ++ pack-objects.h | 2 ++ pack-revindex.h | 2 ++ parse-options.h | 2 ++ patch-ids.h | 3 +++ pathspec.h | 2 ++ progress.h | 2 ++ quote.h | 3 ++- reachable.h | 2 ++ reflog-walk.h| 1 + refs.h | 4 remote.h | 1 + resolve-undo.h | 2 ++ send-pack.h | 4 sequencer.h | 3 +++ sha1-lookup.h| 2 ++ shortlog.h | 2 ++ sideband.h | 2 ++ strbuf.h | 2 ++ submodule.h | 6 -- tag.h| 1 + tree-walk.h | 2 ++ tree.h | 1 + unicode_width.h | 3 +++ unpack-trees.h | 2 ++ url.h| 2 ++ urlmatch.h | 2 ++ utf8.c | 7 --- utf8.h | 9 + vcs-svn/fast_export.h| 5 +++-- vcs-svn/repo_tree.h | 3 ++- vcs-svn/svndiff.h| 5 +++-- wt-status.h | 1 + xdiff/xdiffi.h | 2 ++ xdiff/xemit.h| 1 + xdiff/xprepare.h | 2 ++ xdiff/xutils.h | 2 ++ 76 files changed, 158 insertions(+), 26 deletions(-) diff --git a/archive.h b/archive.h index 4a791e1..b2ca5bf 100644 --- a/archive.h +++ b/archive.h @@ -1,6 +1,7 @@ #ifndef ARCHIVE_H #define ARCHIVE_H +#include cache.h #include pathspec.h struct archiver_args { diff --git a/argv-array.h b/argv-array.h index c65e6e8..7d877af 100644 --- a/argv-array.h +++ b/argv-array.h @@ -1,6 +1,8 @@ #ifndef ARGV_ARRAY_H #define ARGV_ARRAY_H +#include git-compat-util.h + extern const char *empty_argv[]; struct argv_array { diff --git a/attr.h b/attr.h index 8b08d33..34e63f8 100644 --- a/attr.h +++ b/attr.h @@ -1,6 +1,8 @@ #ifndef ATTR_H #define ATTR_H +#include cache.h + /* An attribute is a pointer to this opaque structure */ struct git_attr; diff --git a/branch.h b/branch.h index 64173ab..d5fdcc6 100644 --- a/branch.h +++ b/branch.h @@ -3,6 +3,8 @@ /* Functions for acting on the information about branches. */ +#include cache.h + /* * Creates a new branch, where head is the branch currently checked * out, name is the new branch name, start_name is the name of the diff --git a/builtin.h b/builtin.h index 5d91f31..07c9328 100644 --- a/builtin.h +++ b/builtin.h @@ -1,7 +1,6 @@ #ifndef BUILTIN_H #define BUILTIN_H -#include git-compat-util.h #include strbuf.h #include cache.h #include commit.h diff --git a/cache-tree.h b/cache-tree.h index b47ccec..30b0775 100644 --- a/cache-tree.h +++ b/cache-tree.h @@ -3,6 +3,7 @@ #include tree.h #include tree-walk.h +#include cache.h struct cache_tree; struct cache_tree_sub { diff --git a/cache.h b/cache.h index 4d5b76c..8b827d7 100644 --- a/cache.h +++ b/cache.h @@ -1,7 +1,6 @@ #ifndef CACHE_H #define CACHE_H -#include git-compat-util.h #include strbuf.h #include hashmap.h #include advice.h diff --git a/color.h b/color.h index 9a8495b..6b50a0f 100644 --- a/color.h +++ b/color.h @@ -1,7 +1,8 @@ #ifndef COLOR_H #define COLOR_H -struct strbuf; +#include git-compat-util.h +#include strbuf.h /* 2 + (2 * num_attrs) + 8 + 1 + 8 + 'm' + NUL */ /* \033[1;2;4;5;7;38;5;2xx;48;5;2xxm\0 */ diff --git a/column.h b/column.h index 0a61917..5d094b4
Re: [PATCH v3 2/2] headers: include dependent headers
Am 07.09.2014 um 11:36 schrieb David Aguilar: Add dependent headers so that including a header does not require including additional headers. This makes it so that gcc -c $header succeeds for each header. diff --git a/cache.h b/cache.h index 4d5b76c..8b827d7 100644 --- a/cache.h +++ b/cache.h @@ -1,7 +1,6 @@ #ifndef CACHE_H #define CACHE_H -#include git-compat-util.h #include strbuf.h #include hashmap.h #include advice.h Oh, that's a new change and worth mentioning in the commit message. diff --git a/color.h b/color.h index 9a8495b..6b50a0f 100644 --- a/color.h +++ b/color.h @@ -1,7 +1,8 @@ #ifndef COLOR_H #define COLOR_H -struct strbuf; +#include git-compat-util.h +#include strbuf.h /* 2 + (2 * num_attrs) + 8 + 1 + 8 + 'm' + NUL */ /* \033[1;2;4;5;7;38;5;2xx;48;5;2xxm\0 */ I didn't notice this one the first time around. Isn't the forward declaration of struct strbuf enough? diff --git a/diff.h b/diff.h index b4a624d..27f7696 100644 --- a/diff.h +++ b/diff.h @@ -6,11 +6,11 @@ #include tree-walk.h #include pathspec.h +#include strbuf.h struct rev_info; struct diff_options; struct diff_queue_struct; -struct strbuf; struct diff_filespec; struct userdiff_driver; struct sha1_array; Same here. diff --git a/quote.h b/quote.h index 71dcc3a..37f857b 100644 --- a/quote.h +++ b/quote.h @@ -1,7 +1,8 @@ #ifndef QUOTE_H #define QUOTE_H -struct strbuf; +#include git-compat-util.h +#include strbuf.h /* Help to copy the thing properly quoted for the shell safety. * any single quote is replaced with '\'', any exclamation point And here. diff --git a/submodule.h b/submodule.h index 7beec48..52bb673 100644 --- a/submodule.h +++ b/submodule.h @@ -1,8 +1,10 @@ #ifndef SUBMODULE_H #define SUBMODULE_H -struct diff_options; -struct argv_array; +#include git-compat-util.h +#include diff.h +#include argv-array.h +#include string-list.h enum { RECURSE_SUBMODULES_ON_DEMAND = -1, Similarly here with structs diff_options and argv_array. diff --git a/utf8.c b/utf8.c index b30790d..fb9f299 100644 --- a/utf8.c +++ b/utf8.c @@ -2,13 +2,6 @@ #include strbuf.h #include utf8.h -/* This code is originally from http://www.cl.cam.ac.uk/~mgk25/ucs/ */ - -struct interval { - ucs_char_t first; - ucs_char_t last; -}; - size_t display_mode_esc_sequence_len(const char *s) { const char *p = s; diff --git a/utf8.h b/utf8.h index 65d0e42..af855c5 100644 --- a/utf8.h +++ b/utf8.h @@ -1,8 +1,17 @@ #ifndef GIT_UTF8_H #define GIT_UTF8_H +#include strbuf.h + typedef unsigned int ucs_char_t; /* assuming 32bit int */ +/* This code is originally from http://www.cl.cam.ac.uk/~mgk25/ucs/ */ + +struct interval { + ucs_char_t first; + ucs_char_t last; +}; + size_t display_mode_esc_sequence_len(const char *s); int utf8_width(const char **start, size_t *remainder_p); int utf8_strnwidth(const char *string, int len, int skip_ansi); The move of struct interval was mentioned in the comment section of the first patch. Perhaps include a note in the commit message? diff --git a/vcs-svn/fast_export.h b/vcs-svn/fast_export.h index c8b5adb..7fd5364 100644 --- a/vcs-svn/fast_export.h +++ b/vcs-svn/fast_export.h @@ -1,8 +1,9 @@ #ifndef FAST_EXPORT_H_ #define FAST_EXPORT_H_ -struct strbuf; -struct line_buffer; +#include git-compat-util.h +#include strbuf.h +#include vcs-svn/line_buffer.h void fast_export_init(int fd); void fast_export_deinit(void); struct strbuf forward declaration vs. including strbuf.h again. diff --git a/vcs-svn/repo_tree.h b/vcs-svn/repo_tree.h index 889c6a3..3a946f7 100644 --- a/vcs-svn/repo_tree.h +++ b/vcs-svn/repo_tree.h @@ -1,7 +1,8 @@ #ifndef REPO_TREE_H_ #define REPO_TREE_H_ -struct strbuf; +#include git-compat-util.h +#include strbuf.h #define REPO_MODE_DIR 004 #define REPO_MODE_BLB 0100644 And again. diff --git a/vcs-svn/svndiff.h b/vcs-svn/svndiff.h index 74eb464..d0cbd51 100644 --- a/vcs-svn/svndiff.h +++ b/vcs-svn/svndiff.h @@ -1,8 +1,9 @@ #ifndef SVNDIFF_H_ #define SVNDIFF_H_ -struct line_buffer; -struct sliding_view; +#include git-compat-util.h +#include vcs-svn/line_buffer.h +#include vcs-svn/sliding_window.h extern int svndiff0_apply(struct line_buffer *delta, off_t delta_len, struct sliding_view *preimage, FILE *postimage); Similar issue here with different structs. -- To unsubscribe from this list: send the line unsubscribe git in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
Re: [PATCH v3 2/2] headers: include dependent headers
On 07/09/14 11:35, René Scharfe wrote: Am 07.09.2014 um 11:36 schrieb David Aguilar: Add dependent headers so that including a header does not require including additional headers. This makes it so that gcc -c $header succeeds for each header. diff --git a/cache.h b/cache.h index 4d5b76c..8b827d7 100644 --- a/cache.h +++ b/cache.h @@ -1,7 +1,6 @@ #ifndef CACHE_H #define CACHE_H -#include git-compat-util.h #include strbuf.h #include hashmap.h #include advice.h Oh, that's a new change and worth mentioning in the commit message. Hmm, does this not break git? Unless you also change each '.c' file which includes cache.h to also include git-compat-util.h first, then I suspect (if nothing else) file I/O may be broken. (see _FILE_OFFSET_BITS). Also, see Documentation/CodingGuidelines (lines 331-333). ATB, Ramsay Jones -- To unsubscribe from this list: send the line unsubscribe git in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html