From ebb7baf02f69f2164b1f89148945d18c376fc6a8 Mon Sep 17 00:00:00 2001 From: Ramsay Jones Date: Wed, 19 Sep 2018 01:07:08 +0100 Subject: Makefile: add a hdr-check target Commit ef3ca95475 ("Add missing includes and forward declarations", 2018-08-15) resulted from the author employing a manual method to create a C file consisting of a pair of pre-processor #include lines (for 'git-compat-util.h' and a given toplevel header), and fixing any resulting compiler errors or warnings. Add a Makefile target to automate this process. This implementation relies on the '-include' and '-xc' arguments to the 'gcc' and 'clang' compilers, which allows us to effectively create the required C compilation unit on-the-fly. This limits the portability of this solution to those systems which have such a compiler. The new 'hdr-check' target can be used to check most header files in the project (for various reasons, the 'compat' and 'xdiff' directories are not included). Also, note that individual header files can be checked directly using the '.hco' extension (read: Hdr-Check Object) like so: $ make config.hco HDR config.h $ Signed-off-by: Ramsay Jones Signed-off-by: Junio C Hamano diff --git a/Makefile b/Makefile index b567ccc..835030e 100644 --- a/Makefile +++ b/Makefile @@ -1793,6 +1793,7 @@ ifndef V QUIET_MSGFMT = @echo ' ' MSGFMT $@; QUIET_GCOV = @echo ' ' GCOV $@; QUIET_SP = @echo ' ' SP $<; + QUIET_HDR = @echo ' ' HDR $<; QUIET_RC = @echo ' ' RC $@; QUIET_SUBDIR0 = +@subdir= QUIET_SUBDIR1 = ;$(NO_SUBDIR) echo ' ' SUBDIR $$subdir; \ @@ -2675,6 +2676,17 @@ $(SP_OBJ): %.sp: %.c GIT-CFLAGS FORCE .PHONY: sparse $(SP_OBJ) sparse: $(SP_OBJ) +GEN_HDRS := command-list.h unicode-width.h +EXCEPT_HDRS := $(GEN_HDRS) compat% xdiff% +CHK_HDRS = $(filter-out $(EXCEPT_HDRS),$(patsubst ./%,%,$(LIB_H))) +HCO = $(patsubst %.h,%.hco,$(CHK_HDRS)) + +$(HCO): %.hco: %.h FORCE + $(QUIET_HDR)$(CC) -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 -- cgit v0.10.2-6-g49f6 From bc2133c9d3ebf44b28d0aff5b7328878b6d437fb Mon Sep 17 00:00:00 2001 From: Ramsay Jones Date: Wed, 19 Sep 2018 01:08:35 +0100 Subject: json-writer.h: add missing include (hdr-check) Signed-off-by: Ramsay Jones Signed-off-by: Junio C Hamano diff --git a/json-writer.h b/json-writer.h index fc18acc..83906b0 100644 --- a/json-writer.h +++ b/json-writer.h @@ -42,6 +42,8 @@ * of the given strings. */ +#include "strbuf.h" + struct json_writer { /* -- cgit v0.10.2-6-g49f6 From 9623514aa8286263ad3f04ae476e13759500fc9a Mon Sep 17 00:00:00 2001 From: Ramsay Jones Date: Wed, 19 Sep 2018 01:09:38 +0100 Subject: ewah/ewok_rlw.h: add missing include (hdr-check) Signed-off-by: Ramsay Jones Signed-off-by: Junio C Hamano diff --git a/ewah/ewok_rlw.h b/ewah/ewok_rlw.h index 7cdfdd0..d487966 100644 --- a/ewah/ewok_rlw.h +++ b/ewah/ewok_rlw.h @@ -19,6 +19,8 @@ #ifndef __EWOK_RLW_H__ #define __EWOK_RLW_H__ +#include "ewok.h" + #define RLW_RUNNING_BITS (sizeof(eword_t) * 4) #define RLW_LITERAL_BITS (sizeof(eword_t) * 8 - 1 - RLW_RUNNING_BITS) -- cgit v0.10.2-6-g49f6 From 440984b2d6825402e3fdd823de2def16ea7d56cf Mon Sep 17 00:00:00 2001 From: Ramsay Jones Date: Wed, 19 Sep 2018 01:10:34 +0100 Subject: refs/ref-cache.h: add missing declarations (hdr-check) Signed-off-by: Ramsay Jones Signed-off-by: Junio C Hamano diff --git a/refs/ref-cache.h b/refs/ref-cache.h index eda65e7..3bfb89d 100644 --- a/refs/ref-cache.h +++ b/refs/ref-cache.h @@ -1,7 +1,10 @@ #ifndef REFS_REF_CACHE_H #define REFS_REF_CACHE_H +#include "cache.h" + struct ref_dir; +struct ref_store; /* * If this ref_cache is filled lazily, this function is used to load -- cgit v0.10.2-6-g49f6 From 611023f88f105d3976c546c1b7d9470f51ee1ba4 Mon Sep 17 00:00:00 2001 From: Ramsay Jones Date: Wed, 19 Sep 2018 01:11:44 +0100 Subject: refs/packed-backend.h: add missing declaration (hdr-check) Signed-off-by: Ramsay Jones Signed-off-by: Junio C Hamano diff --git a/refs/packed-backend.h b/refs/packed-backend.h index 640245d..a01a0af 100644 --- a/refs/packed-backend.h +++ b/refs/packed-backend.h @@ -1,6 +1,8 @@ #ifndef REFS_PACKED_BACKEND_H #define REFS_PACKED_BACKEND_H +struct ref_transaction; + /* * Support for storing references in a `packed-refs` file. * -- cgit v0.10.2-6-g49f6 From 4eb4416d37a2f66b0641d91dd0b155fef14266b3 Mon Sep 17 00:00:00 2001 From: Ramsay Jones Date: Wed, 19 Sep 2018 01:12:47 +0100 Subject: refs/refs-internal.h: add missing declarations (hdr-check) Signed-off-by: Ramsay Jones Signed-off-by: Junio C Hamano diff --git a/refs/refs-internal.h b/refs/refs-internal.h index 04425d6..44d5367 100644 --- a/refs/refs-internal.h +++ b/refs/refs-internal.h @@ -1,8 +1,12 @@ #ifndef REFS_REFS_INTERNAL_H #define REFS_REFS_INTERNAL_H +#include "cache.h" +#include "refs.h" #include "iterator.h" +struct ref_transaction; + /* * Data structures and functions for the internal use of the refs * module. Code outside of the refs module should use only the public -- cgit v0.10.2-6-g49f6 From 642e570363c5372182df6bfd3427facc11e67176 Mon Sep 17 00:00:00 2001 From: Ramsay Jones Date: Wed, 19 Sep 2018 01:13:36 +0100 Subject: midx.h: add missing forward declarations (hdr-check) Signed-off-by: Ramsay Jones Reviewed-by: Derrick Stolee Signed-off-by: Junio C Hamano diff --git a/midx.h b/midx.h index a210f1a..622ddac 100644 --- a/midx.h +++ b/midx.h @@ -3,6 +3,9 @@ #include "repository.h" +struct object_id; +struct pack_entry; + struct multi_pack_index { struct multi_pack_index *next; -- cgit v0.10.2-6-g49f6 From 9ce4d21acfedf7e8f153e3506896e8775fe8d70c Mon Sep 17 00:00:00 2001 From: Ramsay Jones Date: Wed, 19 Sep 2018 01:14:30 +0100 Subject: delta-islands.h: add missing forward declarations (hdr-check) Signed-off-by: Ramsay Jones Signed-off-by: Junio C Hamano diff --git a/delta-islands.h b/delta-islands.h index f972573..b635cd0 100644 --- a/delta-islands.h +++ b/delta-islands.h @@ -1,6 +1,10 @@ #ifndef DELTA_ISLANDS_H #define DELTA_ISLANDS_H +struct object_id; +struct packing_data; +struct commit; + int island_delta_cmp(const struct object_id *a, const struct object_id *b); int in_same_island(const struct object_id *, const struct object_id *); void resolve_tree_islands(int progress, struct packing_data *to_pack); -- cgit v0.10.2-6-g49f6