Remove forward declaration of an enum
A message that is not in the archive (sent off-list or not yet received): https://public-inbox.org/git/[email protected]/
v4 cover Add missing includes and forward declares
This series fixes compilation errors when using a simple test.c file that includes git-compat-util.h and then exactly one other header (and repeating this for different headers of git).
Changes in this series come from Jonathan Nieder's reviews; full range-diff follows below, but in summary:
- Squashed the final patch from the previous series into the first (Junio already applied a previous round and resolved the simple conflicts with next and pu, so making it easy to drop doesn't save effort anymore.)
- Added a new patch to the series removing the forward declaration of an enum, for portability reasons.
- Added Jonathan's Reviewed-by on the relevant patches
- Remove a few includes and forward declares (which were initially added in previous rounds of this series) that are no longer necessary (due to other includes)
- Fixed wording in commit message for patch 1 and added some comments about methodology used to come up with the patch.
Elijah Newren (6):
Add missing includes and forward declarations
alloc: make allocate_alloc_state and clear_alloc_state more consistent Move definition of enum branch_track from cache.h to branch.h urlmatch.h: fix include guard
compat/precompose_utf8.h: use more common include guard style Remove forward declaration of an enum
alloc.c | 2 +- alloc.h | 4 +++- apply.h | 3 +++ archive.h | 1 + attr.h | 1 + bisect.h | 2 ++ branch.h | 13 +++++++++++++ bulk-checkin.h | 2 ++ cache.h | 10 ---------- column.h | 1 + commit-graph.h | 1 + compat/precompose_utf8.h | 3 ++- config.c | 1 + config.h | 5 +++++ connected.h | 1 + convert.h | 2 ++ csum-file.h | 2 ++ diffcore.h | 4 ++++ dir-iterator.h | 2 ++ environment.c | 1 + fsck.h | 1 + fsmonitor.h | 3 +++ gpg-interface.h | 2 ++ khash.h | 3 +++ list-objects-filter.h | 4 ++++ list-objects.h | 4 ++++ ll-merge.h | 2 ++ mailinfo.h | 2 ++ mailmap.h | 2 ++ merge-recursive.h | 4 +++- notes-merge.h | 4 ++++ notes-utils.h | 3 +++ notes.h | 3 +++ object-store.h | 1 + object.h | 2 ++ oidmap.h | 1 + pack-bitmap.h | 3 +++ pack-objects.h | 1 + packfile.h | 2 +- patch-ids.h | 6 ++++++ path.h | 1 + pathspec.h | 2 ++ pretty.h | 4 ++++ reachable.h | 2 ++ reflog-walk.h | 1 + refs.h | 2 ++ remote.h | 1 + repository.h | 2 ++ resolve-undo.h | 2 ++ revision.h | 1 + send-pack.h | 4 ++++ sequencer.h | 5 +++++ shortlog.h | 2 ++ submodule.h | 10 ++++++++-- tempfile.h | 1 + trailer.h | 2 ++ tree-walk.h | 2 ++ unpack-trees.h | 5 ++++- url.h | 2 ++ urlmatch.h | 2 ++ utf8.h | 2 ++ worktree.h | 1 + 62 files changed, 152 insertions(+), 18 deletions(-)
1: f7d50cef3b ! 1: e6a93208b2 Add missing includes and forward declares
@@ -1,6 +1,13 @@
Author: Elijah Newren <[email protected]>
- Add missing includes and forward declares
+ Add missing includes and forward declarations
+
+ I looped over the toplevel header files, creating a temporary two-line C
+ program for each consisting of
+ #include "git-compat-util.h"
+ #include $HEADER
+ This patch is the result of manually fixing errors in compiling those
+ tiny programs.
Signed-off-by: Elijah Newren <[email protected]>
@@ -38,15 +45,13 @@
--- a/archive.h
+++ b/archive.h
@@
+ #ifndef ARCHIVE_H
+ #define ARCHIVE_H
++#include "cache.h"
#include "pathspec.h"
-+struct object_id;
-+enum object_type;
-+
struct archiver_args {
- const char *base;
- size_t baselen;
diff --git a/attr.h b/attr.h
--- a/attr.h
@@ -60,6 +65,19 @@
/*
* Given a string, return the gitattribute object that
+diff --git a/bisect.h b/bisect.h
+--- a/bisect.h
++++ b/bisect.h
+@@
+ #ifndef BISECT_H
+ #define BISECT_H
+
++struct commit_list;
++
+ /*
+ * Find bisection. If something is found, `reaches` will be the number of
+ * commits that the best commit reaches. `all` will be the count of
+
diff --git a/branch.h b/branch.h
--- a/branch.h
+++ b/branch.h
@@ -213,10 +231,6 @@
+#include "cache.h"
+#include "dir.h"
-+
-+struct cache_entry;
-+struct index_state;
-+struct strbuf;
+
extern struct trace_key trace_fsmonitor;
@@ -428,6 +442,18 @@
char magic[4];
uint16_t version;
+diff --git a/pack-objects.h b/pack-objects.h
+--- a/pack-objects.h
++++ b/pack-objects.h
+@@
+ #define PACK_OBJECTS_H
+
+ #include "object-store.h"
++#include "pack.h"
+
+ #define DEFAULT_DELTA_CACHE_SIZE (256 * 1024 * 1024)
+
+
diff --git a/patch-ids.h b/patch-ids.h
--- a/patch-ids.h
+++ b/patch-ids.h
@@ -464,9 +490,6 @@
#ifndef PATHSPEC_H
#define PATHSPEC_H
-+#include "string.h"
-+#include "strings.h"
-+
+struct index_state;
+
/* Pathspec magic */2: e46bf7d601 ! 2: f199566088 alloc: make allocate_alloc_state and clear_alloc_state more consistent
@@ -6,6 +6,7 @@
refer to it as void *, or both use the real type (struct alloc_state *).
Opt for the latter.
+ Reviewed-by: Jonathan Nieder <[email protected]>
diff --git a/alloc.c b/alloc.c
3: aec8ddda59 ! 3: 169c90a96f Move definition of enum branch_track from cache.h to branch.h
@@ -7,6 +7,7 @@
for this small enum, just move the enum and the external declaration for git_branch_track to branch.h.
+ Reviewed-by: Jonathan Nieder <[email protected]>
diff --git a/branch.h b/branch.h
4: 14e33fb5ff ! 4: 5a36e50d4d urlmatch.h: fix include guard
@@ -2,6 +2,7 @@
urlmatch.h: fix include guard
+ Reviewed-by: Jonathan Nieder <[email protected]>
diff --git a/urlmatch.h b/urlmatch.h
5: 3e02a381af ! 5: 8f247b24a7 compat/precompose_utf8.h: use more common include guard style
@@ -2,6 +2,7 @@
compat/precompose_utf8.h: use more common include guard style
+ Reviewed-by: Jonathan Nieder <[email protected]>
diff --git a/compat/precompose_utf8.h b/compat/precompose_utf8.h
6: aca61bade1 < -: ---------- Add missing includes and forward declares -: ---------- > 6: 74975b7909 Remove forward declaration of an enum
Signature · 1 line
2.18.0.553.g74975b7909
PATCH v4 1/6 Add missing includes and forward declarations
I looped over the toplevel header files, creating a temporary two-line C program for each consisting of
#include "git-compat-util.h"
#include $HEADER
This patch is the result of manually fixing errors in compiling those tiny programs.
--- alloc.h | 2 ++ apply.h | 3 +++ archive.h | 1 + attr.h | 1 + bisect.h | 2 ++ branch.h | 2 ++ bulk-checkin.h | 2 ++ column.h | 1 + commit-graph.h | 1 + config.h | 5 +++++ connected.h | 1 + convert.h | 2 ++ csum-file.h | 2 ++ diffcore.h | 4 ++++ dir-iterator.h | 2 ++ fsck.h | 1 + fsmonitor.h | 3 +++ gpg-interface.h | 2 ++ khash.h | 3 +++ list-objects-filter.h | 4 ++++ list-objects.h | 4 ++++ ll-merge.h | 2 ++ mailinfo.h | 2 ++ mailmap.h | 2 ++ merge-recursive.h | 4 +++- notes-merge.h | 4 ++++ notes-utils.h | 3 +++ notes.h | 3 +++ object-store.h | 1 + object.h | 2 ++ oidmap.h | 1 + pack-bitmap.h | 3 +++ pack-objects.h | 1 + patch-ids.h | 6 ++++++ path.h | 1 + pathspec.h | 2 ++ pretty.h | 4 ++++ reachable.h | 2 ++ reflog-walk.h | 1 + refs.h | 2 ++ remote.h | 1 + repository.h | 2 ++ resolve-undo.h | 2 ++ revision.h | 1 + send-pack.h | 4 ++++ sequencer.h | 5 +++++ shortlog.h | 2 ++ submodule.h | 10 ++++++++-- tempfile.h | 1 + trailer.h | 2 ++ tree-walk.h | 2 ++ unpack-trees.h | 5 ++++- url.h | 2 ++ utf8.h | 2 ++ worktree.h | 1 + 55 files changed, 132 insertions(+), 4 deletions(-)
alloc.h +2 -0
@@ -1,9 +1,11 @@#ifndef ALLOC_H #define ALLOC_H +struct alloc_state ;struct tree ;struct commit ;struct tag ; +struct repository ;void *alloc_blob_node (struct repository *r);void *alloc_tree_node (struct repository *r);
apply.h +3 -0
@@ -1,6 +1,9 @@#ifndef APPLY_H #define APPLY_H +#include "lockfile.h" +#include "string-list.h" +enum apply_ws_error_action { nowarn_ws_error, warn_on_ws_error,
archive.h +1 -0
@@ -1,6 +1,7 @@#ifndef ARCHIVE_H #define ARCHIVE_H +#include "cache.h" #include "pathspec.h" struct archiver_args {
attr.h +1 -0
@@ -7,6 +7,7 @@ struct git_attr;/* opaque structures used internally for attribute collection */ struct all_attrs_item ;struct attr_stack ; +struct index_state ;/* * Given a string, return the gitattribute object that
bisect.h +2 -0
@@ -1,6 +1,8 @@#ifndef BISECT_H #define BISECT_H +struct commit_list ; +/* * Find bisection. If something is found, `reaches` will be the number of * commits that the best commit reaches. `all` will be the count of
branch.h +2 -0
@@ -1,6 +1,8 @@#ifndef BRANCH_H #define BRANCH_H +struct strbuf ; +/* Functions for acting on the information about branches. */ /*
bulk-checkin.h +2 -0
@@ -4,6 +4,8 @@#ifndef BULK_CHECKIN_H #define BULK_CHECKIN_H +#include "cache.h" +extern int index_bulk_checkin (struct object_id *oid,int fd,size_t size,enum object_type type,const char *path,unsigned flags);
column.h +1 -0
@@ -36,6 +36,7 @@ static inline int column_active(unsigned int colopts)return (colopts &COL_ENABLE_MASK ) ==COL_ENABLED ; } +struct string_list ;extern void print_columns (const struct string_list *list,unsigned int colopts,const struct column_options *opts);
commit-graph.h +1 -0
@@ -4,6 +4,7 @@#include "git-compat-util.h" #include "repository.h" #include "string-list.h" +#include "cache.h" struct commit ;
config.h +5 -0
@@ -1,6 +1,11 @@#ifndef CONFIG_H #define CONFIG_H +#include "hashmap.h" +#include "string-list.h" + +struct object_id ; +/* git_config_parse_key() returns these negated: */ #define CONFIG_INVALID_KEY 1#define CONFIG_NO_SECTION_OR_NAME 2
connected.h +1 -0
@@ -1,6 +1,7 @@#ifndef CONNECTED_H #define CONNECTED_H +struct object_id ;struct transport ;/*
convert.h +2 -0
@@ -7,6 +7,8 @@#include "string-list.h" struct index_state ; +struct object_id ; +struct strbuf ;#define CONV_EOL_RNDTRP_DIE (1<<0)/* Die if CRLF to LF to CRLF is different */ #define CONV_EOL_RNDTRP_WARN (1<<1)/* Warn if CRLF to LF to CRLF is different */
csum-file.h +2 -0
@@ -1,6 +1,8 @@#ifndef CSUM_FILE_H #define CSUM_FILE_H +#include "hash.h" +struct progress ;/* A SHA1-protected file */
diffcore.h +4 -0
@@ -4,6 +4,10 @@#ifndef DIFFCORE_H #define DIFFCORE_H +#include "cache.h" + +struct diff_options ; +/* 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-iterator.h +2 -0
@@ -1,6 +1,8 @@#ifndef DIR_ITERATOR_H #define DIR_ITERATOR_H +#include "strbuf.h" +/* * Iterate over a directory tree. *
fsck.h +1 -0
@@ -6,6 +6,7 @@#define FSCK_IGNORE 3struct fsck_options ; +struct object ;void fsck_set_msg_type (struct fsck_options *options,const char *msg_id,const char *msg_type);
fsmonitor.h +3 -0
@@ -1,6 +1,9 @@#ifndef FSMONITOR_H #define FSMONITOR_H +#include "cache.h" +#include "dir.h" +extern struct trace_key trace_fsmonitor;/*
gpg-interface.h +2 -0
@@ -1,6 +1,8 @@#ifndef GPG_INTERFACE_H #define GPG_INTERFACE_H +struct strbuf ; +#define GPG_VERIFY_VERBOSE 1#define GPG_VERIFY_RAW 2#define GPG_VERIFY_OMIT_STATUS 4
khash.h +3 -0
@@ -26,6 +26,9 @@#ifndef __AC_KHASH_H#define __AC_KHASH_H +#include "cache.h" +#include "hashmap.h" +#define AC_VERSION_KHASH_H "0.2.8"typedef uint32_t khint32_t ;
list-objects-filter.h +4 -0
@@ -1,6 +1,10 @@#ifndef LIST_OBJECTS_FILTER_H #define LIST_OBJECTS_FILTER_H +struct list_objects_filter_options ; +struct object ; +struct oidset ; +/* * During list-object traversal we allow certain objects to be * filtered (omitted) from the result. The active filter uses
list-objects.h +4 -0
@@ -1,6 +1,10 @@#ifndef LIST_OBJECTS_H #define LIST_OBJECTS_H +struct commit ; +struct object ; +struct rev_info ; +typedef void (*show_commit_fn )(struct commit *,void *);typedef void (*show_object_fn )(struct object *,const char *,void *);void traverse_commit_list (struct rev_info *,show_commit_fn ,show_object_fn ,void *);
ll-merge.h +2 -0
@@ -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 */
mailinfo.h +2 -0
@@ -1,6 +1,8 @@#ifndef MAILINFO_H #define MAILINFO_H +#include "strbuf.h" +#define MAX_BOUNDARIES 5 struct mailinfo {
mailmap.h +2 -0
@@ -1,6 +1,8 @@#ifndef MAILMAP_H #define MAILMAP_H +struct string_list ; +int read_mailmap (struct string_list *map,char **repo_abbrev);void clear_mailmap (struct string_list *map);
merge-recursive.h +3 -1
@@ -1,8 +1,10 @@ #ifndef MERGE_RECURSIVE_H #define MERGE_RECURSIVE_H -#include "unpack-trees.h" #include "string-list.h" +#include "unpack-trees.h" + +struct commit; struct merge_options { const char *ancestor;
notes-merge.h +4 -0
@@ -2,6 +2,10 @@#define NOTES_MERGE_H #include "notes-utils.h" +#include "strbuf.h" + +struct commit ; +struct object_id ;#define NOTES_MERGE_WORKTREE "NOTES_MERGE_WORKTREE"
notes-utils.h +3 -0
@@ -3,6 +3,9 @@#include "notes.h" +struct commit_list ; +struct object_id ; +/* * Create new notes commit from the given notes tree *
notes.h +3 -0
@@ -3,6 +3,9 @@#include "string-list.h" +struct object_id ; +struct strbuf ; +/* * Function type for combining two notes annotating the same object. *
object-store.h +1 -0
@@ -1,6 +1,7 @@#ifndef OBJECT_STORE_H #define OBJECT_STORE_H +#include "cache.h" #include "oidmap.h" #include "list.h" #include "sha1-array.h"
object.h +2 -0
@@ -1,6 +1,8 @@#ifndef OBJECT_H #define OBJECT_H +#include "cache.h" +struct buffer_slab ; struct parsed_object_pool {
oidmap.h +1 -0
@@ -1,6 +1,7 @@#ifndef OIDMAP_H #define OIDMAP_H +#include "cache.h" #include "hashmap.h" /*
pack-bitmap.h +3 -0
@@ -5,6 +5,9 @@#include "khash.h" #include "pack-objects.h" +struct commit ; +struct rev_info ; +struct bitmap_disk_header {char magic[4 ];uint16_t version;
pack-objects.h +1 -0
@@ -2,6 +2,7 @@#define PACK_OBJECTS_H #include "object-store.h" +#include "pack.h" #define DEFAULT_DELTA_CACHE_SIZE (256 * 1024 * 1024)
patch-ids.h +6 -0
@@ -1,6 +1,12 @@ #ifndef PATCH_IDS_H #define PATCH_IDS_H +#include "diff.h" +#include "hashmap.h" + +struct commit; +struct object_id; + struct patch_id { struct hashmap_entry ent; struct object_id patch_id;
path.h +1 -0
@@ -2,6 +2,7 @@#define PATH_H struct repository ; +struct strbuf ;/* * The result to all functions which return statically allocated memory may be
pathspec.h +2 -0
@@ -1,6 +1,8 @@#ifndef PATHSPEC_H #define PATHSPEC_H +struct index_state ; +/* Pathspec magic */ #define PATHSPEC_FROMTOP (1<<0)#define PATHSPEC_MAXDEPTH (1<<1)
pretty.h +4 -0
@@ -1,7 +1,11 @@#ifndef PRETTY_H #define PRETTY_H +#include "cache.h" +#include "string-list.h" +struct commit ; +struct strbuf ;/* Commit formats */ enum cmit_fmt {
reachable.h +2 -0
@@ -2,6 +2,8 @@#define REACHEABLE_H struct progress ; +struct rev_info ; +extern int add_unseen_recent_objects_to_traversal (struct rev_info *revs,timestamp_t timestamp); extern void mark_reachable_objects(struct rev_info *revs, int mark_reflog,
reflog-walk.h +1 -0
@@ -3,6 +3,7 @@#include "cache.h" +struct commit ;struct reflog_walk_info ;extern void init_reflog_walk (struct reflog_walk_info **info);
refs.h +2 -0
@@ -3,8 +3,10 @@struct object_id ;struct ref_store ; +struct repository ;struct strbuf ;struct string_list ; +struct string_list_item ;struct worktree ;/*
remote.h +1 -0
@@ -1,6 +1,7 @@#ifndef REMOTE_H #define REMOTE_H +#include "cache.h" #include "parse-options.h" #include "hashmap.h" #include "refspec.h"
repository.h +2 -0
@@ -1,6 +1,8 @@#ifndef REPOSITORY_H #define REPOSITORY_H +#include "path.h" +struct config_set ;struct git_hash_algo ;struct index_state ;
resolve-undo.h +2 -0
@@ -1,6 +1,8 @@ #ifndef RESOLVE_UNDO_H #define RESOLVE_UNDO_H +#include "cache.h" + struct resolve_undo_info { unsigned int mode[3]; struct object_id oid[3];
revision.h +1 -0
@@ -1,6 +1,7 @@#ifndef REVISION_H #define REVISION_H +#include "commit.h" #include "parse-options.h" #include "grep.h" #include "notes.h"
send-pack.h +4 -0
@@ -3,6 +3,10 @@#include "string-list.h" +struct child_process ; +struct oid_array ; +struct ref ; +/* Possible values for push_cert field in send_pack_args. */ #define SEND_PACK_PUSH_CERT_NEVER 0#define SEND_PACK_PUSH_CERT_IF_ASKED 1
sequencer.h +5 -0
@@ -1,6 +1,11 @@#ifndef SEQUENCER_H #define SEQUENCER_H +#include "cache.h" +#include "strbuf.h" + +struct commit ; +const char *git_path_commit_editmsg (void );const char *git_path_seq_dir (void );
shortlog.h +2 -0
@@ -3,6 +3,8 @@#include "string-list.h" +struct commit ; +struct shortlog {struct string_list list;int summary;
submodule.h +8 -2
@@ -1,11 +1,17 @@#ifndef SUBMODULE_H #define SUBMODULE_H -struct repository ; -struct diff_options ;struct argv_array ; +struct cache_entry ; +struct diff_options ; +struct index_state ; +struct object_id ;struct oid_array ; +struct pathspec ;struct remote ; +struct repository ; +struct string_list ; +struct strbuf ;enum { RECURSE_SUBMODULES_ONLY = -5,
tempfile.h +1 -0
@@ -2,6 +2,7 @@#define TEMPFILE_H #include "list.h" +#include "strbuf.h" /* * Handle temporary files.
trailer.h +2 -0
@@ -3,6 +3,8 @@#include "list.h" +struct strbuf ; +enum trailer_where {WHERE_DEFAULT ,WHERE_END ,
tree-walk.h +2 -0
@@ -1,6 +1,8 @@ #ifndef TREE_WALK_H #define TREE_WALK_H +struct strbuf; + struct name_entry { const struct object_id *oid; const char *path;
unpack-trees.h +4 -1
@@ -1,11 +1,14 @@#ifndef UNPACK_TREES_H #define UNPACK_TREES_H -#include "tree-walk.h" +#include "cache.h" #include "argv-array.h" +#include "string-list.h" +#include "tree-walk.h" #define MAX_UNPACK_TREES 8 +struct cache_entry ;struct unpack_trees_options ;struct exclude_list ;
url.h +2 -0
@@ -1,6 +1,8 @@#ifndef URL_H #define URL_H +struct strbuf ; +extern int is_url (const char *url);extern int is_urlschemechar (int first_flag,int ch);extern char *url_decode (const char *url);
utf8.h +2 -0
@@ -1,6 +1,8 @@#ifndef GIT_UTF8_H #define GIT_UTF8_H +struct strbuf ; +typedef unsigned int ucs_char_t ;/* assuming 32bit int */ size_t display_mode_esc_sequence_len (const char *s);
worktree.h +1 -0
@@ -1,6 +1,7 @@#ifndef WORKTREE_H #define WORKTREE_H +#include "cache.h" #include "refs.h" struct strbuf ;
Signature · 1 line
2.18.0.553.g74975b7909
Re: [PATCHv4 1/6] Add missing includes and forward declarations
Elijah Newren wrote:
[...]
Quoted 2 lines
Signed-off-by Elijah Newren <[email protected]>---
[...]
Quoted 1 line
55 files changed, 132 insertions(+), 4 deletions(-)
Thanks.
PATCH v4 2/6 alloc: make allocate_alloc_state and clear_alloc_state more consistent
In reply to Elijah NewrenSince both functions are using the same data type, they should either both refer to it as void *, or both use the real type (struct alloc_state *). Opt for the latter.
--- alloc.c | 2 +- alloc.h | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-)
alloc.c +1 -1
@@ -36,7 +36,7 @@ struct alloc_state {int slab_nr, slab_alloc; }; -void *allocate_alloc_state (void ) +struct alloc_state *allocate_alloc_state (void ) {return xcalloc (1 ,sizeof (struct alloc_state )); }
alloc.h +1 -1
@@ -15,7 +15,7 @@ void *alloc_object_node(struct repository *r);void alloc_report (struct repository *r);unsigned int alloc_commit_index (struct repository *r); -void *allocate_alloc_state (void ); +struct alloc_state *allocate_alloc_state (void );void clear_alloc_state (struct alloc_state *s);#endif
Signature · 1 line
2.18.0.553.g74975b7909
Re: [PATCHv4 2/6] alloc: make allocate_alloc_state and clear_alloc_state more consistent
Quoted 6 lines · Elijah Newren
Since both functions are using the same data type, they should either both refer to it as void *, or both use the real type (struct
alloc_state*). Opt for the latter.Reviewed-by Jonathan Nieder <[email protected]>Signed-off-by Elijah Newren <[email protected]>
Not worth rerolling for this, but these usually go in the opposite order to reflect the chronology:
The patch still looks good to me. :)
PATCH v4 3/6 Move definition of enum branch_track from cache.h to branch.h
In reply to Elijah Newren'branch_track' feels more closely related to branching, and it is needed later in branch.h; rather than #include'ing cache.h in branch.h for this small enum, just move the enum and the external declaration for git_branch_track to branch.h.
--- branch.h | 11 +++++++++++ cache.h | 10 ---------- config.c | 1 + environment.c | 1 + 4 files changed, 13 insertions(+), 10 deletions(-)
branch.h +11 -0
@@ -3,6 +3,17 @@struct strbuf ; +enum branch_track { +BRANCH_TRACK_UNSPECIFIED =-1 , +BRANCH_TRACK_NEVER =0 , +BRANCH_TRACK_REMOTE , +BRANCH_TRACK_ALWAYS , +BRANCH_TRACK_EXPLICIT , +BRANCH_TRACK_OVERRIDE +}; + +extern enum branch_track git_branch_track; +/* Functions for acting on the information about branches. */ /*
cache.h +0 -10
@@ -919,15 +919,6 @@ enum log_refs_config { };extern enum log_refs_config log_all_ref_updates; -enum branch_track { -BRANCH_TRACK_UNSPECIFIED =-1 , -BRANCH_TRACK_NEVER =0 , -BRANCH_TRACK_REMOTE , -BRANCH_TRACK_ALWAYS , -BRANCH_TRACK_EXPLICIT , -BRANCH_TRACK_OVERRIDE -}; -enum rebase_setup_type {AUTOREBASE_NEVER =0 ,AUTOREBASE_LOCAL ,
@@ -944,7 +935,6 @@ enum push_default_type { PUSH_DEFAULT_UNSPECIFIED }; -extern enum branch_track git_branch_track;extern enum rebase_setup_type autorebase;extern enum push_default_type push_default;
config.c +1 -0
@@ -6,6 +6,7 @@* */ #include "cache.h" +#include "branch.h" #include "config.h" #include "repository.h" #include "lockfile.h"
environment.c +1 -0
@@ -8,6 +8,7 @@* are. */ #include "cache.h" +#include "branch.h" #include "repository.h" #include "config.h" #include "refs.h"
Signature · 1 line
2.18.0.553.g74975b7909
PATCH v4 4/6 urlmatch.h: fix include guard
In reply to Elijah Newren--- urlmatch.h | 2 ++ 1 file changed, 2 insertions(+)
urlmatch.h +2 -0
@@ -1,4 +1,6 @@#ifndef URL_MATCH_H +#define URL_MATCH_H +#include "string-list.h" struct url_info {
Signature · 1 line
2.18.0.553.g74975b7909
PATCH v4 5/6 compat/precompose_utf8.h: use more common include guard style
In reply to Elijah Newren--- compat/precompose_utf8.h | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)
compat/precompose_utf8.h +2 -1
@@ -1,4 +1,6 @@#ifndef PRECOMPOSE_UNICODE_H +#define PRECOMPOSE_UNICODE_H +#include <sys/stat.h> #include <sys/types.h> #include <dirent.h>
@@ -41,5 +43,4 @@ int precompose_utf8_closedir(PREC_DIR *dirp);#define DIR PREC_DIR#endif /* PRECOMPOSE_UNICODE_C */ -#define PRECOMPOSE_UNICODE_H #endif /* PRECOMPOSE_UNICODE_H */
Signature · 1 line
2.18.0.553.g74975b7909
PATCH v4 6/6 Remove forward declaration of an enum
In reply to Elijah NewrenAccording to http://c-faq.com/null/machexamp.html, sizeof(char*) != sizeof(int*) on some platforms. Since an enum could be a char or int (or long or...), knowing the size of the enum thus is important to knowing the size of a pointer to an enum, so we cannot just forward declare an enum the way we can a struct. (Also, modern C++ compilers apparently define forward declarations of an enum to either be useless because the enum was defined, or require an explicit size specifier, or be a compilation error.)
--- packfile.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
packfile.h +1 -1
@@ -1,12 +1,12 @@#ifndef PACKFILE_H #define PACKFILE_H +#include "cache.h" #include "oidset.h" /* in object-store.h */ struct packed_git ;struct object_info ; -enum object_type ;/* * Generate the filename to be used for a pack file with checksum "sha1" and
Signature · 1 line
2.18.0.553.g74975b7909
Quoted 8 lines · Elijah Newren
According to http://c-faq.com/null/machexamp.html,
sizeof(char*)!=sizeof(int*)on some platforms. Since an enum could be a char or int (or long or...), knowing the size of the enum thus is important to knowing the size of a pointer to an enum, so we cannot just forward declare an enum the way we can a struct. (Also, modern C++ compilers apparently define forward declarations of an enum to either be useless because the enum was defined, or require an explicit size specifier, or be a compilation error.)
Beyond the effect on some obscure platforms, this also makes it possible to build with gcc -pedantic (which can be useful for finding some other problems). Thanks for fixing it.
[...]
packfile.h line 9
Quoted 12 lines
packfile.h +1
-0@@ -1,12 +1,12 @@#ifndef PACKFILE_H #define PACKFILE_H +#include "cache.h" #include "oidset.h" /* in object-store.h */ struct packed_git ;struct object_info ;
Not about this patch: comments like the above are likely to go stale, since nothing verifies they continue to be true. So we should remove them. #leftoverbits
Re: [PATCHv4 0/6] Add missing includes and forward declares
In reply to Elijah NewrenQuoted 1 line · Elijah Newren
62 files changed, 152 insertions(+), 18 deletions(-)
All 6 patches in this series are
Thanks for your patient work.
Pointer to previous rounds for the curious:
https://public-inbox.org/git/[email protected]/
Re: [PATCHv4 0/6] Add missing includes and forward declares
In reply to Elijah NewrenQuoted 4 lines · Elijah Newren
This series fixes compilation errors when using a simple
test.cfile that includesgit-compat-util.hand then exactly one other header (and repeating this for different headers of git).
[snip]
Quoted 4 lines
1:
f7d50cef3b! 1:e6a93208b2Add missing includes and forward declares
@@ -1,6 +1,13 @@
Author: Elijah Newren <[email protected]>
Quoted 9 lines
- Add missing includes and forward declares
+ Add missing includes and forward declarations
+
+ I looped over the toplevel header files, creating a temporary two-line C
+ program for each consisting of
+ #include "git-compat-util.h"
+ #include $HEADER
+ This patch is the result of manually fixing errors in compiling those
+ tiny programs.
As a quick ("just before bedtime") exercise, I tried adding a Makefile target to perform a similar check. The result is given below, but I haven't had time to look too closely at the results:
$ make -k hdr-check >zzz 2>&1
$ grep error zzz | wc -l
18
$ grep warning zzz | wc -l
21
$ grep error zzz | cut -d: -f1 | grep -v make | uniq -c | sort -nr
11 refs/refs-internal.h
2 unicode-width.h
2 json-writer.h
1 refs/ref-cache.h
1 commit-slab-impl.h
$ grep warning zzz | cut -d: -f1 | grep -v make | uniq -c | sort -nr
7 refs/refs-internal.h
5 delta-islands.h
2 unicode-width.h
2 midx.h
2 commit-reach.h
1 refs/ref-cache.h
1 refs/packed-backend.h
1 pack-bitmap.h
$ BTW, I happen to be on the 'pu' branch.
I think some of the errors are due to missing compiler flags (-I, -D, etc); which flags did you pass to the compiler?
Well, it killed 15min. before bed! ;-)
ATB,
Ramsay Jones
-- >8 --
Subject: [PATCH] Makefile: add a hdr-check target
--- Makefile | 10 ++++++++++ 1 file changed, 10 insertions(+)
Makefile +10 -0
@@ -2684,6 +2684,16 @@ $(SP_OBJ): %.sp: %.c GIT-CFLAGS FORCE .PHONY: sparse $(SP_OBJ) sparse: $(SP_OBJ) +EXCEPT_HDRS := ./compat% ./xdiff% ./ewah% +CHK_HDRS = $(filter-out $(EXCEPT_HDRS),$(LIB_H)) +HCO = $(patsubst %.h,%.hco,$(CHK_HDRS)) + +$(HCO): %.hco: %.h FORCE + $(CC) -Wall -include git-compat-util.h -I. -o /dev/null -c -xc $< + +.PHONY: hdr-check $(HCO) +hdr-check: $(HCO) + .PHONY: style style: git clang-format --style file --diff --extensions c,h
Signature · 1 line
2.18.0
Re: [PATCHv4 0/6] Add missing includes and forward declares
Quoted 9 lines · Ramsay Jones
BTW, I happen to be on the 'pu' branch.
I think some of the errors are due to missing compiler flags (-I, -D, etc); which flags did you pass to the compiler?
Well, it killed 15min. before bed! ;-)
ATB,
Ramsay Jones
It certainly does look fun. I anticipate (read: mostly "hinting that I won't be the one who would be doing so") somebody would make it a real patch, as the current trend seems to be to automate as much checking as we reasonably can.
Quoted 29 lines
-- >8 --
Subject: [PATCH]Makefile: add a hdr-check targetSigned-off-by Ramsay Jones <[email protected]>--- Makefile | 10 ++++++++++ 1 file changed, 10 insertions(+)Makefile +10
-0@@ -2684,6 +2684,16 @@ $(SP_OBJ): %.sp: %.c GIT-CFLAGS FORCE .PHONY: sparse $(SP_OBJ) sparse: $(SP_OBJ) +EXCEPT_HDRS := ./compat% ./xdiff% ./ewah% +CHK_HDRS = $(filter-out $(EXCEPT_HDRS),$(LIB_H)) +HCO = $(patsubst %.h,%.hco,$(CHK_HDRS)) + +$(HCO): %.hco: %.h FORCE + $(CC) -Wall -include git-compat-util.h -I. -o /dev/null -c -xc $< + +.PHONY: hdr-check $(HCO) +hdr-check: $(HCO) + .PHONY: style style: git clang-format --style file --diff --extensions c,h
Re: [PATCHv4 0/6] Add missing includes and forward declares
In reply to Ramsay JonesQuoted 4 lines · Ramsay Jones
As a quick ("just before bedtime") exercise, I tried adding a
Makefiletarget to perform a similar check. The result is given below, but I haven't had time to look too closely at the results:
The resulting patch doesn't look too horrible, and I think it would be great to automate this, even if people don't always run it by default.
The flip side is the "do all files include git-compat-util.h first" test I mentioned elsewhere (and which resulted in the test-tool.h patch). That could be automated, too. I did it like:
{
echo '#undef int'
cat git-compat-util.h
} >tmp
mv tmp git-compat-util.h
make CFLAGS=-Dint=fooThat's obviously pretty nasty, but if we were willing to carry:
#ifdef UNDO_TRICKY_LINT_HACK #undef int #endif
in git-compat-util.h, it could be driven from the Makefile. Maybe worth-while to couple with this.
-Peff