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>
This commit is contained in:
parent
12fd27df79
commit
25c2cab08f
@ -1,6 +1,7 @@
|
|||||||
#include "cache.h"
|
#include "cache.h"
|
||||||
#include "config.h"
|
#include "config.h"
|
||||||
#include "repository.h"
|
#include "repository.h"
|
||||||
|
#include "fsmonitor-ipc.h"
|
||||||
#include "fsmonitor-settings.h"
|
#include "fsmonitor-settings.h"
|
||||||
#include "fsmonitor-path-utils.h"
|
#include "fsmonitor-path-utils.h"
|
||||||
|
|
||||||
@ -242,10 +243,11 @@ enum fsmonitor_reason fsm_settings__get_reason(struct repository *r)
|
|||||||
return r->settings.fsmonitor->reason;
|
return r->settings.fsmonitor->reason;
|
||||||
}
|
}
|
||||||
|
|
||||||
char *fsm_settings__get_incompatible_msg(const struct repository *r,
|
char *fsm_settings__get_incompatible_msg(struct repository *r,
|
||||||
enum fsmonitor_reason reason)
|
enum fsmonitor_reason reason)
|
||||||
{
|
{
|
||||||
struct strbuf msg = STRBUF_INIT;
|
struct strbuf msg = STRBUF_INIT;
|
||||||
|
const char *socket_dir;
|
||||||
|
|
||||||
switch (reason) {
|
switch (reason) {
|
||||||
case FSMONITOR_REASON_UNTESTED:
|
case FSMONITOR_REASON_UNTESTED:
|
||||||
@ -281,9 +283,11 @@ char *fsm_settings__get_incompatible_msg(const struct repository *r,
|
|||||||
goto done;
|
goto done;
|
||||||
|
|
||||||
case FSMONITOR_REASON_NOSOCKETS:
|
case FSMONITOR_REASON_NOSOCKETS:
|
||||||
|
socket_dir = dirname((char *)fsmonitor_ipc__get_path(r));
|
||||||
strbuf_addf(&msg,
|
strbuf_addf(&msg,
|
||||||
_("repository '%s' is incompatible with fsmonitor due to lack of Unix sockets"),
|
_("socket directory '%s' is incompatible with fsmonitor due"
|
||||||
r->worktree);
|
" to lack of Unix sockets support"),
|
||||||
|
socket_dir);
|
||||||
goto done;
|
goto done;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -33,7 +33,7 @@ enum fsmonitor_mode fsm_settings__get_mode(struct repository *r);
|
|||||||
const char *fsm_settings__get_hook_path(struct repository *r);
|
const char *fsm_settings__get_hook_path(struct repository *r);
|
||||||
|
|
||||||
enum fsmonitor_reason fsm_settings__get_reason(struct repository *r);
|
enum fsmonitor_reason fsm_settings__get_reason(struct repository *r);
|
||||||
char *fsm_settings__get_incompatible_msg(const struct repository *r,
|
char *fsm_settings__get_incompatible_msg(struct repository *r,
|
||||||
enum fsmonitor_reason reason);
|
enum fsmonitor_reason reason);
|
||||||
|
|
||||||
struct fsmonitor_settings;
|
struct fsmonitor_settings;
|
||||||
|
@ -295,6 +295,7 @@ static int fsmonitor_force_update_threshold = 100;
|
|||||||
|
|
||||||
void refresh_fsmonitor(struct index_state *istate)
|
void refresh_fsmonitor(struct index_state *istate)
|
||||||
{
|
{
|
||||||
|
static int warn_once = 0;
|
||||||
struct strbuf query_result = STRBUF_INIT;
|
struct strbuf query_result = STRBUF_INIT;
|
||||||
int query_success = 0, hook_version = -1;
|
int query_success = 0, hook_version = -1;
|
||||||
size_t bol = 0; /* beginning of line */
|
size_t bol = 0; /* beginning of line */
|
||||||
@ -305,6 +306,12 @@ void refresh_fsmonitor(struct index_state *istate)
|
|||||||
int is_trivial = 0;
|
int is_trivial = 0;
|
||||||
struct repository *r = istate->repo ? istate->repo : the_repository;
|
struct repository *r = istate->repo ? istate->repo : the_repository;
|
||||||
enum fsmonitor_mode fsm_mode = fsm_settings__get_mode(r);
|
enum fsmonitor_mode fsm_mode = fsm_settings__get_mode(r);
|
||||||
|
enum fsmonitor_reason reason = fsm_settings__get_reason(r);
|
||||||
|
|
||||||
|
if (!warn_once && reason > FSMONITOR_REASON_OK) {
|
||||||
|
warn_once = 1;
|
||||||
|
warning("%s", fsm_settings__get_incompatible_msg(r, reason));
|
||||||
|
}
|
||||||
|
|
||||||
if (fsm_mode <= FSMONITOR_MODE_DISABLED ||
|
if (fsm_mode <= FSMONITOR_MODE_DISABLED ||
|
||||||
istate->fsmonitor_has_run_once)
|
istate->fsmonitor_has_run_once)
|
||||||
|
Loading…
Reference in New Issue
Block a user