From 68d686460f58e45f2eb080e0cdf314987eca5ce5 Mon Sep 17 00:00:00 2001 From: Elijah Newren Date: Tue, 16 May 2023 06:34:08 +0000 Subject: [PATCH] fsmonitor-ll.h: split this header out of fsmonitor.h This creates a new fsmonitor-ll.h with most of the functions from fsmonitor.h, though it leaves three inline functions where they were. Two-thirds of the files that previously included fsmonitor.h did not need those three inline functions or the six extra includes those inline functions required, so this allows them to only include the lower level header. Diff best viewed with `--color-moved`. Signed-off-by: Elijah Newren Signed-off-by: Junio C Hamano --- builtin/fsmonitor--daemon.c | 4 +- compat/fsmonitor/fsm-health-darwin.c | 2 +- compat/fsmonitor/fsm-health-win32.c | 2 +- compat/fsmonitor/fsm-ipc-darwin.c | 2 +- compat/fsmonitor/fsm-listen-darwin.c | 3 +- compat/fsmonitor/fsm-listen-win32.c | 2 +- compat/fsmonitor/fsm-path-utils-darwin.c | 3 +- compat/fsmonitor/fsm-path-utils-win32.c | 3 +- compat/fsmonitor/fsm-settings-darwin.c | 2 +- compat/fsmonitor/fsm-settings-win32.c | 2 +- dir.c | 3 +- fsmonitor-ipc.c | 2 +- fsmonitor-ll.h | 52 ++++++++++++++++++++++++ fsmonitor.h | 46 +-------------------- sparse-index.c | 3 +- 15 files changed, 73 insertions(+), 58 deletions(-) create mode 100644 fsmonitor-ll.h diff --git a/builtin/fsmonitor--daemon.c b/builtin/fsmonitor--daemon.c index f6dd9a784c195e..74d1d6a585d818 100644 --- a/builtin/fsmonitor--daemon.c +++ b/builtin/fsmonitor--daemon.c @@ -5,15 +5,17 @@ #include "environment.h" #include "gettext.h" #include "parse-options.h" -#include "fsmonitor.h" +#include "fsmonitor-ll.h" #include "fsmonitor-ipc.h" #include "fsmonitor-path-utils.h" +#include "fsmonitor-settings.h" #include "compat/fsmonitor/fsm-health.h" #include "compat/fsmonitor/fsm-listen.h" #include "fsmonitor--daemon.h" #include "simple-ipc.h" #include "khash.h" #include "pkt-line.h" +#include "trace.h" #include "trace2.h" static const char * const builtin_fsmonitor__daemon_usage[] = { diff --git a/compat/fsmonitor/fsm-health-darwin.c b/compat/fsmonitor/fsm-health-darwin.c index 4c291f8a066b1b..5b1709d63f729b 100644 --- a/compat/fsmonitor/fsm-health-darwin.c +++ b/compat/fsmonitor/fsm-health-darwin.c @@ -1,6 +1,6 @@ #include "git-compat-util.h" #include "config.h" -#include "fsmonitor.h" +#include "fsmonitor-ll.h" #include "fsm-health.h" #include "fsmonitor--daemon.h" diff --git a/compat/fsmonitor/fsm-health-win32.c b/compat/fsmonitor/fsm-health-win32.c index 6c81d7ee5c22b0..2d4e245beb18b8 100644 --- a/compat/fsmonitor/fsm-health-win32.c +++ b/compat/fsmonitor/fsm-health-win32.c @@ -1,6 +1,6 @@ #include "git-compat-util.h" #include "config.h" -#include "fsmonitor.h" +#include "fsmonitor-ll.h" #include "fsm-health.h" #include "fsmonitor--daemon.h" #include "gettext.h" diff --git a/compat/fsmonitor/fsm-ipc-darwin.c b/compat/fsmonitor/fsm-ipc-darwin.c index 964bc074db60f2..6f3a95410cc100 100644 --- a/compat/fsmonitor/fsm-ipc-darwin.c +++ b/compat/fsmonitor/fsm-ipc-darwin.c @@ -5,7 +5,7 @@ #include "path.h" #include "repository.h" #include "strbuf.h" -#include "fsmonitor.h" +#include "fsmonitor-ll.h" #include "fsmonitor-ipc.h" #include "fsmonitor-path-utils.h" diff --git a/compat/fsmonitor/fsm-listen-darwin.c b/compat/fsmonitor/fsm-listen-darwin.c index 23e24b4b374b3e..36c7e13281c675 100644 --- a/compat/fsmonitor/fsm-listen-darwin.c +++ b/compat/fsmonitor/fsm-listen-darwin.c @@ -24,12 +24,13 @@ #endif #include "git-compat-util.h" -#include "fsmonitor.h" +#include "fsmonitor-ll.h" #include "fsm-listen.h" #include "fsmonitor--daemon.h" #include "fsmonitor-path-utils.h" #include "gettext.h" #include "string-list.h" +#include "trace.h" struct fsm_listen_data { diff --git a/compat/fsmonitor/fsm-listen-win32.c b/compat/fsmonitor/fsm-listen-win32.c index 3c0df5cff8c66b..a361a7db20edbf 100644 --- a/compat/fsmonitor/fsm-listen-win32.c +++ b/compat/fsmonitor/fsm-listen-win32.c @@ -1,6 +1,6 @@ #include "git-compat-util.h" #include "config.h" -#include "fsmonitor.h" +#include "fsmonitor-ll.h" #include "fsm-listen.h" #include "fsmonitor--daemon.h" #include "gettext.h" diff --git a/compat/fsmonitor/fsm-path-utils-darwin.c b/compat/fsmonitor/fsm-path-utils-darwin.c index ef0142e0fbf5cf..049f97eaaf249a 100644 --- a/compat/fsmonitor/fsm-path-utils-darwin.c +++ b/compat/fsmonitor/fsm-path-utils-darwin.c @@ -1,7 +1,8 @@ #include "git-compat-util.h" -#include "fsmonitor.h" +#include "fsmonitor-ll.h" #include "fsmonitor-path-utils.h" #include "gettext.h" +#include "trace.h" #include #include #include diff --git a/compat/fsmonitor/fsm-path-utils-win32.c b/compat/fsmonitor/fsm-path-utils-win32.c index 27bb69451835a1..c8a3e9dcdbb655 100644 --- a/compat/fsmonitor/fsm-path-utils-win32.c +++ b/compat/fsmonitor/fsm-path-utils-win32.c @@ -1,7 +1,8 @@ #include "git-compat-util.h" -#include "fsmonitor.h" +#include "fsmonitor-ll.h" #include "fsmonitor-path-utils.h" #include "gettext.h" +#include "trace.h" /* * Check remote working directory protocol. diff --git a/compat/fsmonitor/fsm-settings-darwin.c b/compat/fsmonitor/fsm-settings-darwin.c index 58b623fbb9a3bf..a3825906351714 100644 --- a/compat/fsmonitor/fsm-settings-darwin.c +++ b/compat/fsmonitor/fsm-settings-darwin.c @@ -1,6 +1,6 @@ #include "git-compat-util.h" #include "config.h" -#include "fsmonitor.h" +#include "fsmonitor-ll.h" #include "fsmonitor-ipc.h" #include "fsmonitor-settings.h" #include "fsmonitor-path-utils.h" diff --git a/compat/fsmonitor/fsm-settings-win32.c b/compat/fsmonitor/fsm-settings-win32.c index 37288978643d7e..b6f67444944b5f 100644 --- a/compat/fsmonitor/fsm-settings-win32.c +++ b/compat/fsmonitor/fsm-settings-win32.c @@ -1,7 +1,7 @@ #include "git-compat-util.h" #include "config.h" #include "repository.h" -#include "fsmonitor.h" +#include "fsmonitor-ll.h" #include "fsmonitor-settings.h" #include "fsmonitor-path-utils.h" diff --git a/dir.c b/dir.c index fada2713b9e8ff..3acac7beb11486 100644 --- a/dir.c +++ b/dir.c @@ -24,7 +24,8 @@ #include "utf8.h" #include "varint.h" #include "ewah/ewok.h" -#include "fsmonitor.h" +#include "fsmonitor-ll.h" +#include "read-cache-ll.h" #include "setup.h" #include "sparse-index.h" #include "submodule-config.h" diff --git a/fsmonitor-ipc.c b/fsmonitor-ipc.c index 6ace978a1b400b..88575aa54cad07 100644 --- a/fsmonitor-ipc.c +++ b/fsmonitor-ipc.c @@ -1,5 +1,5 @@ #include "git-compat-util.h" -#include "fsmonitor.h" +#include "fsmonitor-ll.h" #include "gettext.h" #include "simple-ipc.h" #include "fsmonitor-ipc.h" diff --git a/fsmonitor-ll.h b/fsmonitor-ll.h new file mode 100644 index 00000000000000..0504ca07d62fa1 --- /dev/null +++ b/fsmonitor-ll.h @@ -0,0 +1,52 @@ +#ifndef FSMONITOR_LL_H +#define FSMONITOR_LL_H + +struct index_state; +struct strbuf; + +extern struct trace_key trace_fsmonitor; + +/* + * Read the fsmonitor index extension and (if configured) restore the + * CE_FSMONITOR_VALID state. + */ +int read_fsmonitor_extension(struct index_state *istate, const void *data, unsigned long sz); + +/* + * Fill the fsmonitor_dirty ewah bits with their state from the index, + * before it is split during writing. + */ +void fill_fsmonitor_bitmap(struct index_state *istate); + +/* + * Write the CE_FSMONITOR_VALID state into the fsmonitor index + * extension. Reads from the fsmonitor_dirty ewah in the index. + */ +void write_fsmonitor_extension(struct strbuf *sb, struct index_state *istate); + +/* + * Add/remove the fsmonitor index extension + */ +void add_fsmonitor(struct index_state *istate); +void remove_fsmonitor(struct index_state *istate); + +/* + * Add/remove the fsmonitor index extension as necessary based on the current + * core.fsmonitor setting. + */ +void tweak_fsmonitor(struct index_state *istate); + +/* + * Run the configured fsmonitor integration script and clear the + * CE_FSMONITOR_VALID bit for any files returned as dirty. Also invalidate + * any corresponding untracked cache directory structures. Optimized to only + * run the first time it is called. + */ +void refresh_fsmonitor(struct index_state *istate); + +/* + * Does the received result contain the "trivial" response? + */ +int fsmonitor_is_trivial_response(const struct strbuf *query_result); + +#endif /* FSMONITOR_LL_H */ diff --git a/fsmonitor.h b/fsmonitor.h index 7702301d214a41..5195a8624db82b 100644 --- a/fsmonitor.h +++ b/fsmonitor.h @@ -1,57 +1,13 @@ #ifndef FSMONITOR_H #define FSMONITOR_H +#include "fsmonitor-ll.h" #include "dir.h" #include "fsmonitor-settings.h" #include "object.h" #include "read-cache-ll.h" #include "trace.h" -extern struct trace_key trace_fsmonitor; - -/* - * Read the fsmonitor index extension and (if configured) restore the - * CE_FSMONITOR_VALID state. - */ -int read_fsmonitor_extension(struct index_state *istate, const void *data, unsigned long sz); - -/* - * Fill the fsmonitor_dirty ewah bits with their state from the index, - * before it is split during writing. - */ -void fill_fsmonitor_bitmap(struct index_state *istate); - -/* - * Write the CE_FSMONITOR_VALID state into the fsmonitor index - * extension. Reads from the fsmonitor_dirty ewah in the index. - */ -void write_fsmonitor_extension(struct strbuf *sb, struct index_state *istate); - -/* - * Add/remove the fsmonitor index extension - */ -void add_fsmonitor(struct index_state *istate); -void remove_fsmonitor(struct index_state *istate); - -/* - * Add/remove the fsmonitor index extension as necessary based on the current - * core.fsmonitor setting. - */ -void tweak_fsmonitor(struct index_state *istate); - -/* - * Run the configured fsmonitor integration script and clear the - * CE_FSMONITOR_VALID bit for any files returned as dirty. Also invalidate - * any corresponding untracked cache directory structures. Optimized to only - * run the first time it is called. - */ -void refresh_fsmonitor(struct index_state *istate); - -/* - * Does the received result contain the "trivial" response? - */ -int fsmonitor_is_trivial_response(const struct strbuf *query_result); - /* * Check if refresh_fsmonitor has been called at least once. * refresh_fsmonitor is idempotent. Returns true if fsmonitor is diff --git a/sparse-index.c b/sparse-index.c index 2c47954d933761..90d046225683dd 100644 --- a/sparse-index.c +++ b/sparse-index.c @@ -3,6 +3,7 @@ #include "environment.h" #include "gettext.h" #include "name-hash.h" +#include "read-cache-ll.h" #include "repository.h" #include "sparse-index.h" #include "tree.h" @@ -11,7 +12,7 @@ #include "cache-tree.h" #include "config.h" #include "dir.h" -#include "fsmonitor.h" +#include "fsmonitor-ll.h" struct modify_index_context { struct index_state *write;