fsmonitor: avoid socket location check if using hook

If monitoring is done via fsmonitor hook rather than IPC there is no need to check if the location of the Unix Domain socket (UDS) file is on a remote filesystem. Signed-off-by: Eric DeCosta <edecosta@mathworks.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>

Eric DeCosta committed Oct 4, 2022 at 17:32 UTC 8f44976882b77bb3b9ac0579a04ef05cbea5bdb2
4 files changed +12 -10
compat/fsmonitor/fsm-settings-darwin.c
+6 -4
@@ -48,13 +48,15 @@ static enum fsmonitor_reason check_uds_volume(struct repository *r)
48 return FSMONITOR_REASON_OK;
49 }
50
51 -enum fsmonitor_reason fsm_os__incompatible(struct repository *r)
51 +enum fsmonitor_reason fsm_os__incompatible(struct repository *r, int ipc)
52 {
53 enum fsmonitor_reason reason;
54
55 - reason = check_uds_volume(r);
56 - if (reason != FSMONITOR_REASON_OK)
57 - return reason;
55 + if (ipc) {
56 + reason = check_uds_volume(r);
57 + if (reason != FSMONITOR_REASON_OK)
58 + return reason;
59 + }
60
61 return FSMONITOR_REASON_OK;
62 }
compat/fsmonitor/fsm-settings-win32.c
+1 -1
@@ -25,7 +25,7 @@ static enum fsmonitor_reason check_vfs4git(struct repository *r)
25 return FSMONITOR_REASON_OK;
26 }
27
28 -enum fsmonitor_reason fsm_os__incompatible(struct repository *r)
28 +enum fsmonitor_reason fsm_os__incompatible(struct repository *r, int ipc)
29 {
30 enum fsmonitor_reason reason;
31
fsmonitor-settings.c
+4 -4
@@ -60,7 +60,7 @@ static enum fsmonitor_reason check_remote(struct repository *r)
60 }
61 #endif
62
63 -static enum fsmonitor_reason check_for_incompatible(struct repository *r)
63 +static enum fsmonitor_reason check_for_incompatible(struct repository *r, int ipc)
64 {
65 if (!r->worktree) {
66 /*
@@ -77,7 +77,7 @@ static enum fsmonitor_reason check_for_incompatible(struct repository *r)
77 reason = check_remote(r);
78 if (reason != FSMONITOR_REASON_OK)
79 return reason;
80 - reason = fsm_os__incompatible(r);
80 + reason = fsm_os__incompatible(r, ipc);
81 if (reason != FSMONITOR_REASON_OK)
82 return reason;
83 }
@@ -162,7 +162,7 @@ const char *fsm_settings__get_hook_path(struct repository *r)
162
163 void fsm_settings__set_ipc(struct repository *r)
164 {
165 - enum fsmonitor_reason reason = check_for_incompatible(r);
165 + enum fsmonitor_reason reason = check_for_incompatible(r, 1);
166
167 if (reason != FSMONITOR_REASON_OK) {
168 fsm_settings__set_incompatible(r, reason);
@@ -185,7 +185,7 @@ void fsm_settings__set_ipc(struct repository *r)
185
186 void fsm_settings__set_hook(struct repository *r, const char *path)
187 {
188 - enum fsmonitor_reason reason = check_for_incompatible(r);
188 + enum fsmonitor_reason reason = check_for_incompatible(r, 0);
189
190 if (reason != FSMONITOR_REASON_OK) {
191 fsm_settings__set_incompatible(r, reason);
fsmonitor-settings.h
+1 -1
@@ -48,7 +48,7 @@ struct fsmonitor_settings;
48 * fsm_os__* routines should considered private to fsm_settings__
49 * routines.
50 */
51 -enum fsmonitor_reason fsm_os__incompatible(struct repository *r);
51 +enum fsmonitor_reason fsm_os__incompatible(struct repository *r, int ipc);
52 #endif /* HAVE_FSMONITOR_OS_SETTINGS */
53
54 #endif /* FSMONITOR_SETTINGS_H */