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