* [PATCH 0/2] Remove unnecessary inclusions of parse-options.h from headers
@ 2023-03-19 16:27 SZEDER Gábor
2023-03-19 16:27 ` [PATCH 1/2] treewide: include parse-options.h in source files SZEDER Gábor
` (2 more replies)
0 siblings, 3 replies; 4+ messages in thread
From: SZEDER Gábor @ 2023-03-19 16:27 UTC (permalink / raw)
To: git; +Cc: SZEDER Gábor
Some source files use parse_options(), but don't include
parse-options.h, while some headers do include parse-options.h, though
don't really need it. These patches fix these issues.
This series has a small and simple conflict with the 'ds/ahead-behind'
topic, and it will have small conflicts with Elijah's header cleanup
series as well:
https://public-inbox.org/git/pull.1493.git.1679207282.gitgitgadget@gmail.com/T/#t
SZEDER Gábor (2):
treewide: include parse-options.h in source files
treewide: remove unnecessary inclusions of parse-options.h from
headers
builtin/ls-remote.c | 1 +
builtin/pack-objects.c | 1 +
builtin/receive-pack.c | 1 +
builtin/reflog.c | 1 +
builtin/send-pack.c | 1 +
diagnose.c | 1 +
diagnose.h | 3 ++-
list-objects-filter-options.c | 1 +
list-objects-filter-options.h | 3 ++-
ref-filter.h | 2 +-
remote.c | 1 +
remote.h | 2 +-
revision.c | 1 +
revision.h | 3 ++-
send-pack.c | 1 +
15 files changed, 18 insertions(+), 5 deletions(-)
--
2.40.0.499.g88fa0b00d2
^ permalink raw reply [flat|nested] 4+ messages in thread
* [PATCH 1/2] treewide: include parse-options.h in source files
2023-03-19 16:27 [PATCH 0/2] Remove unnecessary inclusions of parse-options.h from headers SZEDER Gábor
@ 2023-03-19 16:27 ` SZEDER Gábor
2023-03-19 16:27 ` [PATCH 2/2] treewide: remove unnecessary inclusions of parse-options.h from headers SZEDER Gábor
2023-03-20 16:41 ` [PATCH 0/2] Remove " Elijah Newren
2 siblings, 0 replies; 4+ messages in thread
From: SZEDER Gábor @ 2023-03-19 16:27 UTC (permalink / raw)
To: git; +Cc: SZEDER Gábor
The builtins 'ls-remote', 'pack-objects', 'receive-pack', 'reflog' and
'send-pack' use parse_options(), but their source files don't directly
include 'parse-options.h'. Furthermore, the source files
'diagnose.c', 'list-objects-filter-options.c', 'remote.c' and
'send-pack.c' define option parsing callback functions, while
'revision.c' defines an option parsing helper function, and thus need
access to various fields in 'struct option' and 'struct
parse_opt_ctx_t', but they don't directly include 'parse-options.h'
either. They all can still be built, of course, because they include
one of the header files that does include 'parse-options.h' (though
unnecessarily, see the next commit).
Add those missing includes to these files, as our general rule is that
"a C file must directly include the header files that declare the
functions and the types it uses".
Signed-off-by: SZEDER Gábor <szeder.dev@gmail.com>
---
builtin/ls-remote.c | 1 +
builtin/pack-objects.c | 1 +
builtin/receive-pack.c | 1 +
builtin/reflog.c | 1 +
builtin/send-pack.c | 1 +
diagnose.c | 1 +
list-objects-filter-options.c | 1 +
remote.c | 1 +
revision.c | 1 +
send-pack.c | 1 +
10 files changed, 10 insertions(+)
diff --git a/builtin/ls-remote.c b/builtin/ls-remote.c
index 2dfbd8ed9b..a9de0575ce 100644
--- a/builtin/ls-remote.c
+++ b/builtin/ls-remote.c
@@ -5,6 +5,7 @@
#include "ref-filter.h"
#include "remote.h"
#include "refs.h"
+#include "parse-options.h"
static const char * const ls_remote_usage[] = {
N_("git ls-remote [--heads] [--tags] [--refs] [--upload-pack=<exec>]\n"
diff --git a/builtin/pack-objects.c b/builtin/pack-objects.c
index 545b8bddc8..7e9e20172a 100644
--- a/builtin/pack-objects.c
+++ b/builtin/pack-objects.c
@@ -39,6 +39,7 @@
#include "shallow.h"
#include "promisor-remote.h"
#include "pack-mtimes.h"
+#include "parse-options.h"
/*
* Objects we are going to pack are collected in the `to_pack` structure.
diff --git a/builtin/receive-pack.c b/builtin/receive-pack.c
index fe68c79ee3..fcc87595ac 100644
--- a/builtin/receive-pack.c
+++ b/builtin/receive-pack.c
@@ -31,6 +31,7 @@
#include "commit-reach.h"
#include "worktree.h"
#include "shallow.h"
+#include "parse-options.h"
static const char * const receive_pack_usage[] = {
N_("git receive-pack <git-dir>"),
diff --git a/builtin/reflog.c b/builtin/reflog.c
index 270681dcdf..9b000bb6bc 100644
--- a/builtin/reflog.c
+++ b/builtin/reflog.c
@@ -4,6 +4,7 @@
#include "reachable.h"
#include "worktree.h"
#include "reflog.h"
+#include "parse-options.h"
#define BUILTIN_REFLOG_SHOW_USAGE \
N_("git reflog [show] [<log-options>] [<ref>]")
diff --git a/builtin/send-pack.c b/builtin/send-pack.c
index fb5b2bad2c..42a04ed6fc 100644
--- a/builtin/send-pack.c
+++ b/builtin/send-pack.c
@@ -16,6 +16,7 @@
#include "gpg-interface.h"
#include "gettext.h"
#include "protocol.h"
+#include "parse-options.h"
static const char * const send_pack_usage[] = {
N_("git send-pack [--mirror] [--dry-run] [--force]\n"
diff --git a/diagnose.c b/diagnose.c
index 5b398f0cff..998f517c48 100644
--- a/diagnose.c
+++ b/diagnose.c
@@ -8,6 +8,7 @@
#include "strvec.h"
#include "object-store.h"
#include "packfile.h"
+#include "parse-options.h"
struct archive_dir {
const char *path;
diff --git a/list-objects-filter-options.c b/list-objects-filter-options.c
index 1d25a5737d..72aeb089cc 100644
--- a/list-objects-filter-options.c
+++ b/list-objects-filter-options.c
@@ -11,6 +11,7 @@
#include "promisor-remote.h"
#include "trace.h"
#include "url.h"
+#include "parse-options.h"
static int parse_combine_filter(
struct list_objects_filter_options *filter_options,
diff --git a/remote.c b/remote.c
index b04e5da338..641b083d90 100644
--- a/remote.c
+++ b/remote.c
@@ -17,6 +17,7 @@
#include "commit-reach.h"
#include "advice.h"
#include "connect.h"
+#include "parse-options.h"
enum map_direction { FROM_SRC, FROM_DST };
diff --git a/revision.c b/revision.c
index e4c066e90b..8b1ecf07fc 100644
--- a/revision.c
+++ b/revision.c
@@ -37,6 +37,7 @@
#include "json-writer.h"
#include "list-objects-filter-options.h"
#include "resolve-undo.h"
+#include "parse-options.h"
volatile show_early_output_fn_t show_early_output;
diff --git a/send-pack.c b/send-pack.c
index 423a5cfe22..0d05191162 100644
--- a/send-pack.c
+++ b/send-pack.c
@@ -17,6 +17,7 @@
#include "gpg-interface.h"
#include "cache.h"
#include "shallow.h"
+#include "parse-options.h"
int option_parse_push_signed(const struct option *opt,
const char *arg, int unset)
--
2.40.0.499.g88fa0b00d2
^ permalink raw reply related [flat|nested] 4+ messages in thread
* [PATCH 2/2] treewide: remove unnecessary inclusions of parse-options.h from headers
2023-03-19 16:27 [PATCH 0/2] Remove unnecessary inclusions of parse-options.h from headers SZEDER Gábor
2023-03-19 16:27 ` [PATCH 1/2] treewide: include parse-options.h in source files SZEDER Gábor
@ 2023-03-19 16:27 ` SZEDER Gábor
2023-03-20 16:41 ` [PATCH 0/2] Remove " Elijah Newren
2 siblings, 0 replies; 4+ messages in thread
From: SZEDER Gábor @ 2023-03-19 16:27 UTC (permalink / raw)
To: git; +Cc: SZEDER Gábor
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>
---
diagnose.h | 3 ++-
list-objects-filter-options.h | 3 ++-
ref-filter.h | 2 +-
remote.h | 2 +-
revision.h | 3 ++-
5 files changed, 8 insertions(+), 5 deletions(-)
diff --git a/diagnose.h b/diagnose.h
index 7a4951a786..f525219ab0 100644
--- a/diagnose.h
+++ b/diagnose.h
@@ -2,7 +2,8 @@
#define DIAGNOSE_H
#include "strbuf.h"
-#include "parse-options.h"
+
+struct option;
enum diagnose_mode {
DIAGNOSE_NONE,
diff --git a/list-objects-filter-options.h b/list-objects-filter-options.h
index ef03b45132..727c986122 100644
--- a/list-objects-filter-options.h
+++ b/list-objects-filter-options.h
@@ -2,10 +2,11 @@
#define LIST_OBJECTS_FILTER_OPTIONS_H
#include "object.h"
-#include "parse-options.h"
#include "string-list.h"
#include "strbuf.h"
+struct option;
+
/*
* The list of defined filters for list-objects.
*/
diff --git a/ref-filter.h b/ref-filter.h
index aa0eea4ecf..daa6d02017 100644
--- a/ref-filter.h
+++ b/ref-filter.h
@@ -4,7 +4,6 @@
#include "oid-array.h"
#include "refs.h"
#include "commit.h"
-#include "parse-options.h"
/* Quoting styles */
#define QUOTE_NONE 0
@@ -24,6 +23,7 @@
struct atom_value;
struct ref_sorting;
+struct option;
enum ref_sorting_order {
REF_SORTING_REVERSE = 1<<0,
diff --git a/remote.h b/remote.h
index 5b38ee20b8..73638cefeb 100644
--- a/remote.h
+++ b/remote.h
@@ -1,10 +1,10 @@
#ifndef REMOTE_H
#define REMOTE_H
-#include "parse-options.h"
#include "hashmap.h"
#include "refspec.h"
+struct option;
struct transport_ls_refs_options;
/**
diff --git a/revision.h b/revision.h
index ab71443696..649f817f39 100644
--- a/revision.h
+++ b/revision.h
@@ -2,7 +2,6 @@
#define REVISION_H
#include "commit.h"
-#include "parse-options.h"
#include "grep.h"
#include "notes.h"
#include "pretty.h"
@@ -62,6 +61,8 @@ struct string_list;
struct saved_parents;
struct bloom_key;
struct bloom_filter_settings;
+struct option;
+struct parse_opt_ctx_t;
define_shared_commit_slab(revision_sources, char *);
struct rev_cmdline_info {
--
2.40.0.499.g88fa0b00d2
^ permalink raw reply related [flat|nested] 4+ messages in thread
* Re: [PATCH 0/2] Remove unnecessary inclusions of parse-options.h from headers
2023-03-19 16:27 [PATCH 0/2] Remove unnecessary inclusions of parse-options.h from headers SZEDER Gábor
2023-03-19 16:27 ` [PATCH 1/2] treewide: include parse-options.h in source files SZEDER Gábor
2023-03-19 16:27 ` [PATCH 2/2] treewide: remove unnecessary inclusions of parse-options.h from headers SZEDER Gábor
@ 2023-03-20 16:41 ` Elijah Newren
2 siblings, 0 replies; 4+ messages in thread
From: Elijah Newren @ 2023-03-20 16:41 UTC (permalink / raw)
To: SZEDER Gábor; +Cc: git
On Sun, Mar 19, 2023 at 10:13 AM SZEDER Gábor <szeder.dev@gmail.com> wrote:
>
> Some source files use parse_options(), but don't include
> parse-options.h, while some headers do include parse-options.h, though
> don't really need it. These patches fix these issues.
Nice!
Reviewed-by: Elijah Newren <newren@gmail.com>
> This series has a small and simple conflict with the 'ds/ahead-behind'
> topic, and it will have small conflicts with Elijah's header cleanup
> series as well:
>
> https://public-inbox.org/git/pull.1493.git.1679207282.gitgitgadget@gmail.com/T/#t
Perhaps it makes sense to rebase your series on that one? (And/or add
the headers earlier in the list instead of at the end to reduce the
odds of patch collisions? I really wish we had our #include's in
alphabetical order instead of always appending to the end, because it
both reduces the odds of conflicts and is so much easier for humans to
check.)
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2023-03-20 16:50 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-03-19 16:27 [PATCH 0/2] Remove unnecessary inclusions of parse-options.h from headers SZEDER Gábor
2023-03-19 16:27 ` [PATCH 1/2] treewide: include parse-options.h in source files SZEDER Gábor
2023-03-19 16:27 ` [PATCH 2/2] treewide: remove unnecessary inclusions of parse-options.h from headers SZEDER Gábor
2023-03-20 16:41 ` [PATCH 0/2] Remove " Elijah Newren
Code repositories for project(s) associated with this public inbox
https://80x24.org/mirrors/git.git
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).