Git fork

fsmonitor: check for compatability before communicating with fsmonitor

If fsmonitor is not in a compatible state, warn with an appropriate message.

Signed-off-by: Eric DeCosta <edecosta@mathworks.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>

authored by

Eric DeCosta and committed by
Junio C Hamano
25c2cab0 12fd27df

+15 -4
+7 -3
fsmonitor-settings.c
··· 1 #include "cache.h" 2 #include "config.h" 3 #include "repository.h" 4 #include "fsmonitor-settings.h" 5 #include "fsmonitor-path-utils.h" 6 ··· 242 return r->settings.fsmonitor->reason; 243 } 244 245 - char *fsm_settings__get_incompatible_msg(const struct repository *r, 246 enum fsmonitor_reason reason) 247 { 248 struct strbuf msg = STRBUF_INIT; 249 250 switch (reason) { 251 case FSMONITOR_REASON_UNTESTED: ··· 281 goto done; 282 283 case FSMONITOR_REASON_NOSOCKETS: 284 strbuf_addf(&msg, 285 - _("repository '%s' is incompatible with fsmonitor due to lack of Unix sockets"), 286 - r->worktree); 287 goto done; 288 } 289
··· 1 #include "cache.h" 2 #include "config.h" 3 #include "repository.h" 4 + #include "fsmonitor-ipc.h" 5 #include "fsmonitor-settings.h" 6 #include "fsmonitor-path-utils.h" 7 ··· 243 return r->settings.fsmonitor->reason; 244 } 245 246 + char *fsm_settings__get_incompatible_msg(struct repository *r, 247 enum fsmonitor_reason reason) 248 { 249 struct strbuf msg = STRBUF_INIT; 250 + const char *socket_dir; 251 252 switch (reason) { 253 case FSMONITOR_REASON_UNTESTED: ··· 283 goto done; 284 285 case FSMONITOR_REASON_NOSOCKETS: 286 + socket_dir = dirname((char *)fsmonitor_ipc__get_path(r)); 287 strbuf_addf(&msg, 288 + _("socket directory '%s' is incompatible with fsmonitor due" 289 + " to lack of Unix sockets support"), 290 + socket_dir); 291 goto done; 292 } 293
+1 -1
fsmonitor-settings.h
··· 33 const char *fsm_settings__get_hook_path(struct repository *r); 34 35 enum fsmonitor_reason fsm_settings__get_reason(struct repository *r); 36 - char *fsm_settings__get_incompatible_msg(const struct repository *r, 37 enum fsmonitor_reason reason); 38 39 struct fsmonitor_settings;
··· 33 const char *fsm_settings__get_hook_path(struct repository *r); 34 35 enum fsmonitor_reason fsm_settings__get_reason(struct repository *r); 36 + char *fsm_settings__get_incompatible_msg(struct repository *r, 37 enum fsmonitor_reason reason); 38 39 struct fsmonitor_settings;
+7
fsmonitor.c
··· 295 296 void refresh_fsmonitor(struct index_state *istate) 297 { 298 struct strbuf query_result = STRBUF_INIT; 299 int query_success = 0, hook_version = -1; 300 size_t bol = 0; /* beginning of line */ ··· 305 int is_trivial = 0; 306 struct repository *r = istate->repo ? istate->repo : the_repository; 307 enum fsmonitor_mode fsm_mode = fsm_settings__get_mode(r); 308 309 if (fsm_mode <= FSMONITOR_MODE_DISABLED || 310 istate->fsmonitor_has_run_once)
··· 295 296 void refresh_fsmonitor(struct index_state *istate) 297 { 298 + static int warn_once = 0; 299 struct strbuf query_result = STRBUF_INIT; 300 int query_success = 0, hook_version = -1; 301 size_t bol = 0; /* beginning of line */ ··· 306 int is_trivial = 0; 307 struct repository *r = istate->repo ? istate->repo : the_repository; 308 enum fsmonitor_mode fsm_mode = fsm_settings__get_mode(r); 309 + enum fsmonitor_reason reason = fsm_settings__get_reason(r); 310 + 311 + if (!warn_once && reason > FSMONITOR_REASON_OK) { 312 + warn_once = 1; 313 + warning("%s", fsm_settings__get_incompatible_msg(r, reason)); 314 + } 315 316 if (fsm_mode <= FSMONITOR_MODE_DISABLED || 317 istate->fsmonitor_has_run_once)