Skip to content

Commit

Permalink
fsmonitor-ll.h: split this header out of fsmonitor.h
Browse files Browse the repository at this point in the history
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 <newren@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
  • Loading branch information
newren authored and gitster committed Jun 21, 2023
1 parent b9a7ac2 commit 68d6864
Show file tree
Hide file tree
Showing 15 changed files with 73 additions and 58 deletions.
4 changes: 3 additions & 1 deletion builtin/fsmonitor--daemon.c
Original file line number Diff line number Diff line change
Expand Up @@ -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[] = {
Expand Down
2 changes: 1 addition & 1 deletion compat/fsmonitor/fsm-health-darwin.c
Original file line number Diff line number Diff line change
@@ -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"

Expand Down
2 changes: 1 addition & 1 deletion compat/fsmonitor/fsm-health-win32.c
Original file line number Diff line number Diff line change
@@ -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"
Expand Down
2 changes: 1 addition & 1 deletion compat/fsmonitor/fsm-ipc-darwin.c
Original file line number Diff line number Diff line change
Expand Up @@ -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"

Expand Down
3 changes: 2 additions & 1 deletion compat/fsmonitor/fsm-listen-darwin.c
Original file line number Diff line number Diff line change
Expand Up @@ -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
{
Expand Down
2 changes: 1 addition & 1 deletion compat/fsmonitor/fsm-listen-win32.c
Original file line number Diff line number Diff line change
@@ -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"
Expand Down
3 changes: 2 additions & 1 deletion compat/fsmonitor/fsm-path-utils-darwin.c
Original file line number Diff line number Diff line change
@@ -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 <dirent.h>
#include <errno.h>
#include <fcntl.h>
Expand Down
3 changes: 2 additions & 1 deletion compat/fsmonitor/fsm-path-utils-win32.c
Original file line number Diff line number Diff line change
@@ -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.
Expand Down
2 changes: 1 addition & 1 deletion compat/fsmonitor/fsm-settings-darwin.c
Original file line number Diff line number Diff line change
@@ -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"
Expand Down
2 changes: 1 addition & 1 deletion compat/fsmonitor/fsm-settings-win32.c
Original file line number Diff line number Diff line change
@@ -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"

Expand Down
3 changes: 2 additions & 1 deletion dir.c
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down
2 changes: 1 addition & 1 deletion fsmonitor-ipc.c
Original file line number Diff line number Diff line change
@@ -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"
Expand Down
52 changes: 52 additions & 0 deletions fsmonitor-ll.h
Original file line number Diff line number Diff line change
@@ -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 */
46 changes: 1 addition & 45 deletions fsmonitor.h
Original file line number Diff line number Diff line change
@@ -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
Expand Down
3 changes: 2 additions & 1 deletion sparse-index.c
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand All @@ -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;
Expand Down

0 comments on commit 68d6864

Please sign in to comment.