treewide: remove unnecessary inclusions of parse-options.h from headers

The headers 'diagnose.h', 'list-objects-filter-options.h', 'ref-filter.h' and 'remote.h' declare option parsing callback functions with a 'struct option*' parameter, and 'revision.h' declares an option parsing helper function taking 'struct parse_opt_ctx_t*' and 'struct option*' parameters. These headers all include 'parse-options.h', although they don't need any of the type definitions from that header file. Furthermore, 'list-objects-filter-options.h' and 'ref-filter.h' also define some OPT_* macros to initialize a 'struct option', but these don't necessitate the inclusion of parse-options.h in these headers either, because these macros are only expanded in source files. Remove these unnecessary inclusions of parse-options.h and use forward declarations to declare the necessary types. After this patch none of the header files include parse-options.h anymore. With these changes, the build time after modifying only parse-options.h is reduced by about 30%, and the number of targets built is almost 20% less: Before: $ touch parse-options.h && time make -j4 |wc -l 353 real 1m1.527s user 3m32.205s sys 0m15.903s After: 289 real 0m39.285s user 2m12.540s sys 0m11.164s Signed-off-by: SZEDER Gábor <szeder.dev@gmail.com> Reviewed-by: Elijah Newren <newren@gmail.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>

SZEDER Gábor committed Mar 19, 2023 at 17:27 UTC c4d9c79378e9108358c3f20e27bc437754cd805d
5 files changed +8 -5
diagnose.h
+2 -1
@@ -2,7 +2,8 @@
2 #define DIAGNOSE_H
3
4 #include "strbuf.h"
5 -#include "parse-options.h"
5 +
6 +struct option;
7
8 enum diagnose_mode {
9 DIAGNOSE_NONE,
list-objects-filter-options.h
+2 -1
@@ -2,9 +2,10 @@
2 #define LIST_OBJECTS_FILTER_OPTIONS_H
3
4 #include "cache.h"
5 -#include "parse-options.h"
5 #include "string-list.h"
6
7 +struct option;
8 +
9 /*
10 * The list of defined filters for list-objects.
11 */
ref-filter.h
+1 -1
@@ -4,7 +4,6 @@
4 #include "oid-array.h"
5 #include "refs.h"
6 #include "commit.h"
7 -#include "parse-options.h"
7
8 /* Quoting styles */
9 #define QUOTE_NONE 0
@@ -24,6 +23,7 @@
23
24 struct atom_value;
25 struct ref_sorting;
26 +struct option;
27
28 enum ref_sorting_order {
29 REF_SORTING_REVERSE = 1<<0,
remote.h
+1 -1
@@ -2,10 +2,10 @@
2 #define REMOTE_H
3
4 #include "cache.h"
5 -#include "parse-options.h"
5 #include "hashmap.h"
6 #include "refspec.h"
7
8 +struct option;
9 struct transport_ls_refs_options;
10
11 /**
revision.h
+2 -1
@@ -2,7 +2,6 @@
2 #define REVISION_H
3
4 #include "commit.h"
5 -#include "parse-options.h"
5 #include "grep.h"
6 #include "notes.h"
7 #include "pretty.h"
@@ -61,6 +60,8 @@ struct string_list;
60 struct saved_parents;
61 struct bloom_key;
62 struct bloom_filter_settings;
63 +struct option;
64 +struct parse_opt_ctx_t;
65 define_shared_commit_slab(revision_sources, char *);
66
67 struct rev_cmdline_info {