MCPcopy Index your code
hub / github.com/git/git / refresh_fsmonitor

Function refresh_fsmonitor

fsmonitor.c:506–726  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

504static int fsmonitor_force_update_threshold = 100;
505
506void refresh_fsmonitor(struct index_state *istate)
507{
508 static int warn_once = 0;
509 struct strbuf query_result = STRBUF_INIT;
510 int query_success = 0, hook_version = -1;
511 size_t bol = 0; /* beginning of line */
512 uint64_t last_update;
513 struct strbuf last_update_token = STRBUF_INIT;
514 char *buf;
515 unsigned int i;
516 int is_trivial = 0;
517 struct repository *r = istate->repo;
518 enum fsmonitor_mode fsm_mode = fsm_settings__get_mode(r);
519 enum fsmonitor_reason reason = fsm_settings__get_reason(r);
520
521 if (!warn_once && reason > FSMONITOR_REASON_OK) {
522 char *msg = fsm_settings__get_incompatible_msg(r, reason);
523 warn_once = 1;
524 warning("%s", msg);
525 free(msg);
526 }
527
528 if (fsm_mode <= FSMONITOR_MODE_DISABLED ||
529 istate->fsmonitor_has_run_once)
530 return;
531
532 istate->fsmonitor_has_run_once = 1;
533
534 trace_printf_key(&trace_fsmonitor, "refresh fsmonitor");
535
536 if (fsm_mode == FSMONITOR_MODE_IPC) {
537 query_success = !fsmonitor_ipc__send_query(
538 istate->fsmonitor_last_update ?
539 istate->fsmonitor_last_update : "builtin:fake",
540 &query_result);
541 if (query_success) {
542 /*
543 * The response contains a series of nul terminated
544 * strings. The first is the new token.
545 *
546 * Use `char *buf` as an interlude to trick the CI
547 * static analysis to let us use `strbuf_addstr()`
548 * here (and only copy the token) rather than
549 * `strbuf_addbuf()`.
550 */
551 buf = query_result.buf;
552 strbuf_addstr(&last_update_token, buf);
553 bol = last_update_token.len + 1;
554 is_trivial = query_result.buf[bol] == '/';
555 if (is_trivial)
556 trace2_data_intmax("fsm_client", NULL,
557 "query/trivial-response", 1);
558 } else {
559 /*
560 * The builtin daemon is not available on this
561 * platform -OR- we failed to get a response.
562 *
563 * Generate a fake token (rather than a V1

Callers 7

add_fsmonitorFunction · 0.85
tweak_fsmonitorFunction · 0.85
valid_cached_dirFunction · 0.85
run_diff_filesFunction · 0.85
run_diff_indexFunction · 0.85
ie_match_statFunction · 0.85
refresh_cache_entFunction · 0.85

Calls 14

fsm_settings__get_modeFunction · 0.85
fsm_settings__get_reasonFunction · 0.85
warningFunction · 0.85
strbuf_addstrFunction · 0.85
fsmonitor_hook_versionFunction · 0.85
getnanotimeFunction · 0.85
strbuf_addfFunction · 0.85
query_fsmonitor_hookFunction · 0.85

Tested by

no test coverage detected