Skip to contentSkip to conversation

headers: include dependent headers

PATCH In review David Aguilar 3 participants 5 messages Jun 15, 2016

lore
Share & tools
lore
#0 lore raw

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.

---
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(-)
archive.h +1 -0
index 4a791e1..b2ca5bf 100644
@@ -1,6 +1,7 @@
 #ifndef ARCHIVE_H
 #define ARCHIVE_H
 
+#include "cache.h"
 #include "pathspec.h"
 
 struct archiver_args {
argv-array.h +2 -0
index c65e6e8..7d877af 100644
@@ -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 {
attr.h +2 -0
index 8b08d33..34e63f8 100644
@@ -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;
 
branch.h +2 -0
index 64173ab..d5fdcc6 100644
@@ -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
builtin.h +0 -1
index 5d91f31..07c9328 100644
@@ -1,7 +1,6 @@
 #ifndef BUILTIN_H
 #define BUILTIN_H
 
-#include "git-compat-util.h"
 #include "strbuf.h"
 #include "cache.h"
 #include "commit.h"
cache-tree.h +1 -0
index b47ccec..30b0775 100644
@@ -3,6 +3,7 @@
 
 #include "tree.h"
 #include "tree-walk.h"
+#include "cache.h"
 
 struct cache_tree;
 struct cache_tree_sub {
cache.h +0 -1
index 4d5b76c..8b827d7 100644
@@ -1,7 +1,6 @@
 #ifndef CACHE_H
 #define CACHE_H
 
-#include "git-compat-util.h"
 #include "strbuf.h"
 #include "hashmap.h"
 #include "advice.h"
color.h +2 -1
index 9a8495b..6b50a0f 100644
@@ -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" */
column.h +2 -0
index 0a61917..5d094b4 100644
@@ -1,6 +1,8 @@
 #ifndef COLUMN_H
 #define COLUMN_H
 
+#include "string-list.h"
+
 #define COL_LAYOUT_MASK   0x000F
 #define COL_ENABLE_MASK   0x0030   /* always, never or auto */
 #define COL_PARSEOPT      0x0040   /* --column is given from cmdline */
commit.h +1 -1
index aa8c3ca..dddc876 100644
@@ -3,10 +3,10 @@
 
 #include "object.h"
 #include "tree.h"
-#include "strbuf.h"
 #include "decorate.h"
 #include "gpg-interface.h"
 #include "string-list.h"
+#include "cache.h"
 
 struct commit_list {
 	struct commit *item;
compat/bswap.h +7 -0
index f6fd9a6..0c164be 100644
@@ -1,3 +1,8 @@
+#ifndef COMPAT_BSWAP_H
+#define COMPAT_BSWAP_H
+
+#include "git-compat-util.h"
+
 /*
  * Let's make sure we always have a sane definition for ntohl()/htonl().
  * Some libraries define those as a function call, just to perform byte
@@ -173,3 +178,5 @@ static inline uint64_t git_bswap64(uint64_t x)
 	*((unsigned char *)(p) + 3) = __v >>  0; } while (0)
 
 #endif
+
+#endif
compat/precompose_utf8.h +3 -5
index 3b73585..34d1051 100644
@@ -1,9 +1,8 @@
 #ifndef PRECOMPOSE_UNICODE_H
-#include <sys/stat.h>
-#include <sys/types.h>
-#include <dirent.h>
-#include <iconv.h>
+#define  PRECOMPOSE_UNICODE_H
 
+#include "git-compat-util.h"
+#include <iconv.h>
 
 typedef struct dirent_prec_psx {
 	ino_t d_ino;            /* Posix */
@@ -41,5 +40,4 @@ int precompose_utf8_closedir(PREC_DIR *dirp);
 #define DIR PREC_DIR
 #endif /* PRECOMPOSE_UNICODE_C */
 
-#define  PRECOMPOSE_UNICODE_H
 #endif /* PRECOMPOSE_UNICODE_H */
convert.h +3 -0
index 0c2143c..bb3266b 100644
@@ -4,6 +4,9 @@
 #ifndef CONVERT_H
 #define CONVERT_H
 
+#include "git-compat-util.h"
+#include "strbuf.h"
+
 enum safe_crlf {
 	SAFE_CRLF_FALSE = 0,
 	SAFE_CRLF_FAIL = 1,
credential.h +1 -0
index 0c3e85e..cfa87f1 100644
@@ -1,6 +1,7 @@
 #ifndef CREDENTIAL_H
 #define CREDENTIAL_H
 
+#include "git-compat-util.h"
 #include "string-list.h"
 
 struct credential {
csum-file.h +2 -0
index bb543d5..9e29e35 100644
@@ -1,6 +1,8 @@
 #ifndef CSUM_FILE_H
 #define CSUM_FILE_H
 
+#include "cache.h"
+
 struct progress;
 
 /* A SHA1-protected file */
delta.h +2 -0
index 9b67531..668e163 100644
@@ -1,6 +1,8 @@
 #ifndef DELTA_H
 #define DELTA_H
 
+#include "git-compat-util.h"
+
 /* opaque object for delta index */
 struct delta_index;
 
diff.h +1 -1
index b4a624d..27f7696 100644
@@ -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;
diffcore.h +2 -0
index c876dac..1f3290c 100644
@@ -4,6 +4,8 @@
 #ifndef DIFFCORE_H
 #define DIFFCORE_H
 
+#include "diff.h"
+
 /* This header file is internal between diff.c and its diff transformers
  * (e.g. diffcore-rename, diffcore-pickaxe).  Never include this header
  * in anything else.
dir.h +2 -1
index 6c45e9d..6b00001 100644
@@ -3,7 +3,8 @@
 
 /* See Documentation/technical/api-directory-listing.txt */
 
-#include "strbuf.h"
+#include "pathspec.h"
+#include "cache.h"
 
 struct dir_entry {
 	unsigned int len;
ewah/ewok.h +2 -0
index f6ad190..7812863 100644
@@ -20,6 +20,8 @@
 #ifndef __EWOK_BITMAP_H__
 #define __EWOK_BITMAP_H__
 
+#include "git-compat-util.h"
+
 #ifndef ewah_malloc
 #	define ewah_malloc xmalloc
 #endif
ewah/ewok_rlw.h +2 -0
index 63efdf9..b34dfa1 100644
@@ -20,6 +20,8 @@
 #ifndef __EWOK_RLW_H__
 #define __EWOK_RLW_H__
 
+#include "ewah/ewok.h"
+
 #define RLW_RUNNING_BITS (sizeof(eword_t) * 4)
 #define RLW_LITERAL_BITS (sizeof(eword_t) * 8 - 1 - RLW_RUNNING_BITS)
 
exec_cmd.h +2 -0
index e4c9702..daa26e2 100644
@@ -1,6 +1,8 @@
 #ifndef GIT_EXEC_CMD_H
 #define GIT_EXEC_CMD_H
 
+#include "git-compat-util.h"
+
 extern void git_set_argv_exec_path(const char *exec_path);
 extern const char *git_extract_argv0_path(const char *path);
 extern const char *git_exec_path(void);
fsck.h +2 -0
index 1e4f527..99b2802 100644
@@ -1,6 +1,8 @@
 #ifndef GIT_FSCK_H
 #define GIT_FSCK_H
 
+#include "object.h"
+
 #define FSCK_ERROR 1
 #define FSCK_WARN 2
 
gpg-interface.h +2 -0
index 37c23da..f42b706 100644
@@ -1,6 +1,8 @@
 #ifndef GPG_INTERFACE_H
 #define GPG_INTERFACE_H
 
+#include "strbuf.h"
+
 struct signature_check {
 	char *payload;
 	char *gpg_output;
graph.h +2 -0
index 0be62bd..17e6a11 100644
@@ -1,6 +1,8 @@
 #ifndef GRAPH_H
 #define GRAPH_H
 
+#include "revision.h"
+
 /* A graph is a pointer to this opaque structure */
 struct git_graph;
 
hashmap.h +2 -0
index ab7958a..8605fae 100644
@@ -1,6 +1,8 @@
 #ifndef HASHMAP_H
 #define HASHMAP_H
 
+#include "git-compat-util.h"
+
 /*
  * Generic implementation of hash-based key-value mappings.
  * See Documentation/technical/api-hashmap.txt.
help.h +2 -0
index b21d7c9..a3bf882 100644
@@ -1,6 +1,8 @@
 #ifndef HELP_H
 #define HELP_H
 
+#include "git-compat-util.h"
+
 struct cmdnames {
 	int alloc;
 	int cnt;
khash.h +2 -0
index 06c7906..fc8b1bf 100644
@@ -26,6 +26,8 @@
 #ifndef __AC_KHASH_H
 #define __AC_KHASH_H
 
+#include "cache.h"
+
 #define AC_VERSION_KHASH_H "0.2.8"
 
 typedef uint32_t khint32_t;
kwset.h +2 -0
index a21b2ea..2acc585 100644
@@ -25,6 +25,8 @@
    The author may be reached (Email) at the address [email protected],
    or (US mail) as Mike Haertel c/o Free Software Foundation. */
 
+#include "git-compat-util.h"
+
 struct kwsmatch
 {
   int index;			/* Index number of matching keyword. */
line-log.h +1 -0
index a9212d8..e1d47e0 100644
@@ -2,6 +2,7 @@
 #define LINE_LOG_H
 
 #include "diffcore.h"
+#include "string-list.h"
 
 struct rev_info;
 struct commit;
list-objects.h +2 -0
index 136a1da..8810db6 100644
@@ -1,6 +1,8 @@
 #ifndef LIST_OBJECTS_H
 #define LIST_OBJECTS_H
 
+#include "revision.h"
+
 typedef void (*show_commit_fn)(struct commit *, void *);
 typedef void (*show_object_fn)(struct object *, const struct name_path *, const char *, void *);
 void traverse_commit_list(struct rev_info *, show_commit_fn, show_object_fn, void *);
ll-merge.h +2 -0
index 244a31f..b72b199 100644
@@ -5,6 +5,8 @@
 #ifndef LL_MERGE_H
 #define LL_MERGE_H
 
+#include "xdiff/xdiff.h"
+
 struct ll_merge_options {
 	unsigned virtual_ancestor : 1;
 	unsigned variant : 2;	/* favor ours, favor theirs, or union merge */
mailmap.h +3 -0
index ed7c93b..27ac3c7 100644
@@ -1,6 +1,9 @@
 #ifndef MAILMAP_H
 #define MAILMAP_H
 
+#include "git-compat-util.h"
+#include "string-list.h"
+
 int read_mailmap(struct string_list *map, char **repo_abbrev);
 void clear_mailmap(struct string_list *map);
 
merge-recursive.h +2 -0
index 9e090a3..05500b3 100644
@@ -1,7 +1,9 @@
 #ifndef MERGE_RECURSIVE_H
 #define MERGE_RECURSIVE_H
 
+#include "strbuf.h"
 #include "string-list.h"
+#include "commit.h"
 
 struct merge_options {
 	const char *ancestor;
notes-cache.h +1 -0
index 356f88f..4ecd767 100644
@@ -1,6 +1,7 @@
 #ifndef NOTES_CACHE_H
 #define NOTES_CACHE_H
 
+#include "git-compat-util.h"
 #include "notes.h"
 
 struct notes_cache {
notes-merge.h +3 -0
index 1d01f6a..73d961d 100644
@@ -1,6 +1,9 @@
 #ifndef NOTES_MERGE_H
 #define NOTES_MERGE_H
 
+#include "notes.h"
+#include "commit.h"
+
 #define NOTES_MERGE_WORKTREE "NOTES_MERGE_WORKTREE"
 
 enum notes_merge_verbosity {
notes-utils.h +1 -0
index 890ddb3..eaac967 100644
@@ -2,6 +2,7 @@
 #define NOTES_UTILS_H
 
 #include "notes.h"
+#include "commit.h"
 
 /*
  * Create new notes commit from the given notes tree
notes.h +1 -0
index 2a3f923..12318a4 100644
@@ -1,6 +1,7 @@
 #ifndef NOTES_H
 #define NOTES_H
 
+#include "strbuf.h"
 #include "string-list.h"
 
 /*
object.h +2 -0
index 5e8d8ee..e61b290 100644
@@ -1,6 +1,8 @@
 #ifndef OBJECT_H
 #define OBJECT_H
 
+#include "cache.h"
+
 struct object_list {
 	struct object *item;
 	struct object_list *next;
pack-bitmap.h +2 -0
index 8b7f4e9..945ff30 100644
@@ -1,9 +1,11 @@
 #ifndef PACK_BITMAP_H
 #define PACK_BITMAP_H
 
+#include "git-compat-util.h"
 #include "ewah/ewok.h"
 #include "khash.h"
 #include "pack-objects.h"
+#include "revision.h"
 
 struct bitmap_disk_entry {
 	uint32_t object_pos;
pack-objects.h +2 -0
index d1b98b3..2c28bea 100644
@@ -1,6 +1,8 @@
 #ifndef PACK_OBJECTS_H
 #define PACK_OBJECTS_H
 
+#include "pack.h"
+
 struct object_entry {
 	struct pack_idx_entry idx;
 	unsigned long size;	/* uncompressed size */
pack-revindex.h +2 -0
index d737f98..4e574b3 100644
@@ -1,6 +1,8 @@
 #ifndef PACK_REVINDEX_H
 #define PACK_REVINDEX_H
 
+#include "git-compat-util.h"
+
 struct revindex_entry {
 	off_t offset;
 	unsigned int nr;
parse-options.h +2 -0
index 7940bc7..933a1b7 100644
@@ -1,6 +1,8 @@
 #ifndef PARSE_OPTIONS_H
 #define PARSE_OPTIONS_H
 
+#include "git-compat-util.h"
+
 enum parse_opt_type {
 	/* special types */
 	OPTION_END,
patch-ids.h +3 -0
index c8c7ca1..016eb2d 100644
@@ -1,6 +1,9 @@
 #ifndef PATCH_IDS_H
 #define PATCH_IDS_H
 
+#include "commit.h"
+#include "diff.h"
+
 struct patch_id {
 	unsigned char patch_id[20];
 	char seen;
pathspec.h +2 -0
index 0c11262..c92fafc 100644
@@ -1,6 +1,8 @@
 #ifndef PATHSPEC_H
 #define PATHSPEC_H
 
+#include "git-compat-util.h"
+
 /* Pathspec magic */
 #define PATHSPEC_FROMTOP	(1<<0)
 #define PATHSPEC_MAXDEPTH	(1<<1)
progress.h +2 -0
index 611e4c4..4c78a2c 100644
@@ -1,6 +1,8 @@
 #ifndef PROGRESS_H
 #define PROGRESS_H
 
+#include "git-compat-util.h"
+
 struct progress;
 
 void display_throughput(struct progress *progress, off_t total);
quote.h +2 -1
index 71dcc3a..37f857b 100644
@@ -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
reachable.h +2 -0
index 5d082ad..5536382 100644
@@ -1,6 +1,8 @@
 #ifndef REACHEABLE_H
 #define REACHEABLE_H
 
+#include "revision.h"
+
 struct progress;
 extern void mark_reachable_objects(struct rev_info *revs, int mark_reflog, struct progress *);
 
reflog-walk.h +1 -0
index 50265f5..d5378b9 100644
@@ -2,6 +2,7 @@
 #define REFLOG_WALK_H
 
 #include "cache.h"
+#include "commit.h"
 
 struct reflog_walk_info;
 
refs.h +4 -0
index ec46acd..5c43232 100644
@@ -1,6 +1,10 @@
 #ifndef REFS_H
 #define REFS_H
 
+#include "git-compat-util.h"
+#include "strbuf.h"
+#include "string-list.h"
+
 struct ref_lock {
 	char *ref_name;
 	char *orig_ref_name;
remote.h +1 -0
index 8b62efd..24bcbd7 100644
@@ -3,6 +3,7 @@
 
 #include "parse-options.h"
 #include "hashmap.h"
+#include "strbuf.h"
 
 enum {
 	REMOTE_CONFIG,
resolve-undo.h +2 -0
index 4630645..815050d 100644
@@ -1,6 +1,8 @@
 #ifndef RESOLVE_UNDO_H
 #define RESOLVE_UNDO_H
 
+#include "cache.h"
+
 struct resolve_undo_info {
 	unsigned int mode[3];
 	unsigned char sha1[3][20];
send-pack.h +4 -0
index 8e84392..f0c463a 100644
@@ -1,6 +1,10 @@
 #ifndef SEND_PACK_H
 #define SEND_PACK_H
 
+#include "git-compat-util.h"
+#include "run-command.h"
+#include "remote.h"
+
 struct send_pack_args {
 	unsigned verbose:1,
 		quiet:1,
sequencer.h +3 -0
index db43e9c..c817247 100644
@@ -1,6 +1,9 @@
 #ifndef SEQUENCER_H
 #define SEQUENCER_H
 
+#include "git-compat-util.h"
+#include "strbuf.h"
+
 #define SEQ_DIR		"sequencer"
 #define SEQ_HEAD_FILE	"sequencer/head"
 #define SEQ_TODO_FILE	"sequencer/todo"
sha1-lookup.h +2 -0
index 20af285..f375596 100644
@@ -1,6 +1,8 @@
 #ifndef SHA1_LOOKUP_H
 #define SHA1_LOOKUP_H
 
+#include "git-compat-util.h"
+
 typedef const unsigned char *sha1_access_fn(size_t index, void *table);
 
 extern int sha1_pos(const unsigned char *sha1,
shortlog.h +2 -0
index de4f86f..e5949e7 100644
@@ -1,6 +1,8 @@
 #ifndef SHORTLOG_H
 #define SHORTLOG_H
 
+#include "git-compat-util.h"
+#include "commit.h"
 #include "string-list.h"
 
 struct shortlog {
sideband.h +2 -0
index e46bed0..411aa51 100644
@@ -1,6 +1,8 @@
 #ifndef SIDEBAND_H
 #define SIDEBAND_H
 
+#include "git-compat-util.h"
+
 #define SIDEBAND_PROTOCOL_ERROR -2
 #define SIDEBAND_REMOTE_ERROR -1
 
strbuf.h +2 -0
index 7bdc1da..c3ea9a2 100644
@@ -1,6 +1,8 @@
 #ifndef STRBUF_H
 #define STRBUF_H
 
+#include "git-compat-util.h"
+
 /* See Documentation/technical/api-strbuf.txt */
 
 extern char strbuf_slopbuf[];
submodule.h +4 -2
index 7beec48..52bb673 100644
@@ -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,
tag.h +1 -0
index bc8a1e4..68b0334 100644
@@ -1,6 +1,7 @@
 #ifndef TAG_H
 #define TAG_H
 
+#include "git-compat-util.h"
 #include "object.h"
 
 extern const char *tag_type;
tree-walk.h +2 -0
index ae7fb3a..0818126 100644
@@ -1,6 +1,8 @@
 #ifndef TREE_WALK_H
 #define TREE_WALK_H
 
+#include "strbuf.h"
+
 struct name_entry {
 	const unsigned char *sha1;
 	const char *path;
tree.h +1 -0
index d84ac63..9565406 100644
@@ -2,6 +2,7 @@
 #define TREE_H
 
 #include "object.h"
+#include "pathspec.h"
 
 extern const char *tree_type;
 
unicode_width.h +3 -0
index 47cdd23..b35bdc4 100644
@@ -1,3 +1,6 @@
+#include "git-compat-util.h"
+#include "utf8.h"
+
 static const struct interval zero_width[] = {
 { 0x0300, 0x036F },
 { 0x0483, 0x0489 },
unpack-trees.h +2 -0
index 36a73a6..e4792ec 100644
@@ -1,7 +1,9 @@
 #ifndef UNPACK_TREES_H
 #define UNPACK_TREES_H
 
+#include "cache.h"
 #include "string-list.h"
+#include "tree-walk.h"
 
 #define MAX_UNPACK_TREES 8
 
url.h +2 -0
index abdaf6f..f4a23c3 100644
@@ -1,6 +1,8 @@
 #ifndef URL_H
 #define URL_H
 
+#include "strbuf.h"
+
 extern int is_url(const char *url);
 extern int is_urlschemechar(int first_flag, int ch);
 extern char *url_decode(const char *url);
urlmatch.h +2 -0
index b461dfd..9f7c781 100644
@@ -1,4 +1,6 @@
 #ifndef URL_MATCH_H
+
+#include "git-compat-util.h"
 #include "string-list.h"
 
 struct url_info {
utf8.c +0 -7
index b30790d..fb9f299 100644
@@ -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;
utf8.h +9 -0
index 65d0e42..af855c5 100644
@@ -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);
vcs-svn/fast_export.h +3 -2
index c8b5adb..7fd5364 100644
@@ -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);
vcs-svn/repo_tree.h +2 -1
index 889c6a3..3a946f7 100644
@@ -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 0040000
 #define REPO_MODE_BLB 0100644
vcs-svn/svndiff.h +3 -2
index 74eb464..d0cbd51 100644
@@ -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);
wt-status.h +1 -0
index 283a9fe..38f930a 100644
@@ -4,6 +4,7 @@
 #include <stdio.h>
 #include "string-list.h"
 #include "color.h"
+#include "pathspec.h"
 
 enum color_wt_status {
 	WT_STATUS_HEADER = 0,
xdiff/xdiffi.h +2 -0
index 8b81206..d1f0e1d 100644
@@ -23,6 +23,8 @@
 #if !defined(XDIFFI_H)
 #define XDIFFI_H
 
+#include "xdiff.h"
+#include "xtypes.h"
 
 typedef struct s_diffdata {
 	long nrec;
xdiff/xemit.h +1 -0
index d297107..ad719ad 100644
@@ -23,6 +23,7 @@
 #if !defined(XEMIT_H)
 #define XEMIT_H
 
+#include "xdiffi.h"
 
 typedef int (*emit_func_t)(xdfenv_t *xe, xdchange_t *xscr, xdemitcb_t *ecb,
 			   xdemitconf_t const *xecfg);
xdiff/xprepare.h +2 -0
index 8fb06a5..a2958cf 100644
@@ -23,6 +23,8 @@
 #if !defined(XPREPARE_H)
 #define XPREPARE_H
 
+#include "xdiff.h"
+#include "xtypes.h"
 
 
 int xdl_prepare_env(mmfile_t *mf1, mmfile_t *mf2, xpparam_t const *xpp,
xdiff/xutils.h +2 -0
index 4646ce5..a55237b 100644
@@ -23,6 +23,8 @@
 #if !defined(XUTILS_H)
 #define XUTILS_H
 
+#include "xdiff.h"
+#include "xtypes.h"
 
 
 long xdl_bogosqrt(long n);
Signature · 1 line
2.1.0.62.g724b830
#1 lore raw

Am 07.09.2014 um 11:36 schrieb David Aguilar:

Quoted 10 lines

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.

cache.h +0 -0
index 4d5b76c..8b827d7 100644

cache.h line 6

Quoted 7 lines
cache.h +0 -1
@@ -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.

Quoted 5 lines
color.h +0 -0
index 9a8495b..6b50a0f 100644

color.h line 8

Quoted 9 lines
color.h +2 -1
@@ -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?

Quoted 7 lines
diff.h +0 -0
index b4a624d..27f7696 100644
@@ -6,11 +6,11 @@
 
  #include "tree-walk.h"

diff.h line 16

Quoted 10 lines
diff.h +1 -1
  #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.

Quoted 5 lines
quote.h +0 -0
index 71dcc3a..37f857b 100644

quote.h line 8

Quoted 9 lines
quote.h +2 -1
@@ -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.

Quoted 7 lines
submodule.h +0 -0
index 7beec48..52bb673 100644
@@ -1,8 +1,10 @@
  #ifndef SUBMODULE_H
  #define SUBMODULE_H

submodule.h line 10

Quoted 10 lines
submodule.h +4 -2
 
-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.

Quoted 30 lines
utf8.c +0 -7
index b30790d..fb9f299 100644
@@ -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;
utf8.h +2 -0
index 65d0e42..af855c5 100644
@@ -1,8 +1,17 @@
  #ifndef GIT_UTF8_H
  #define GIT_UTF8_H
 
+#include "strbuf.h"
+
  typedef unsigned int ucs_char_t;  /* assuming 32bit int */
 

utf8.h line 17

Quoted 10 lines
utf8.h +7 -0
+/* 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?

Quoted 6 lines
vcs-svn/fast_export.h +0 -0
index c8b5adb..7fd5364 100644
@@ -1,8 +1,9 @@
  #ifndef FAST_EXPORT_H_

vcs-svn/fast_export.h line 9

Quoted 10 lines
vcs-svn/fast_export.h +3 -2
  #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.

Quoted 5 lines
vcs-svn/repo_tree.h +0 -0
index 889c6a3..3a946f7 100644

vcs-svn/repo_tree.h line 8

Quoted 9 lines
vcs-svn/repo_tree.h +2 -1
@@ -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 0040000
  #define REPO_MODE_BLB 0100644

And again.

Quoted 6 lines
vcs-svn/svndiff.h +0 -0
index 74eb464..d0cbd51 100644
@@ -1,8 +1,9 @@
  #ifndef SVNDIFF_H_

vcs-svn/svndiff.h line 9

Quoted 10 lines
vcs-svn/svndiff.h +3 -2
  #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.

#2 lore raw
Quoted 14 lines · René Scharfe

Am 07.09.2014 um 11:36 schrieb David Aguilar:

Quoted 13 lines

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.

cache.h +0 -0
index 4d5b76c..8b827d7 100644
@@ -1,7 +1,6 @@
  #ifndef CACHE_H
  #define CACHE_H
 
Quoted 6 lines

cache.h line 6

Quoted 4 lines
cache.h +0 -1
-#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

#3 lore raw
Quoted 22 lines · Ramsay Jones
Quoted 14 lines · René Scharfe

Am 07.09.2014 um 11:36 schrieb David Aguilar:

Quoted 13 lines

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.

cache.h +0 -0
index 4d5b76c..8b827d7 100644
@@ -1,7 +1,6 @@
  #ifndef CACHE_H
  #define CACHE_H
 
Quoted 6 lines

cache.h line 6

Quoted 4 lines
cache.h +0 -1
-#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.

Quoted 5 lines

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).

This one should be okay because hashmap.h includes git-compat-util.h.

Jonathan will be re-rolling so I'll definitely read and test the patches when they're ready. They'll probably be a more focused, surgical change then this version.

cheers,

Signature · 1 line
David
#4 lore raw
Quoted 23 lines · David Aguilar
Quoted 22 lines · Ramsay Jones
Quoted 20 lines · René Scharfe

Am 07.09.2014 um 11:36 schrieb David Aguilar:

Quoted 10 lines

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.

cache.h +0 -0
index 4d5b76c..8b827d7 100644

cache.h line 6

Quoted 7 lines
cache.h +0 -1
@@ -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.

Quoted 7 lines
Quoted 5 lines

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).

This one should be okay because hashmap.h includes git-compat-util.h.

It is important that each compilation unit include 'git-compat-util.h' at the start. From the CodingGuidelines we see that 'cache.h' and 'builtin.h' are *blessed* headers which can be used instead. (I have always thought that this was a mistake; it would be much easier to just stick to using 'git-compat-util.h' at the top of each '.c' file ;-)

The fact that hashmap.h happens to include git-compat-util.h is not at all relevant here.

Quoted 4 lines

Jonathan will be re-rolling so I'll definitely read and test the patches when they're ready. They'll probably be a more focused, surgical change then this version.

OK.

ATB,
Ramsay Jones