Skip to content

Commit 7763928

Browse files
jeffhostetlerdscho
authored andcommitted
fsmonitor: use IPC to query the builtin FSMonitor daemon
Use simple IPC to directly communicate with the new builtin file system monitor daemon when `core.useBuiltinFSMonitor` is set. The `core.fsmonitor` setting has already been defined as a HOOK pathname. Historically, this has been set to a HOOK script that will talk with Watchman. For compatibility reasons, we do not want to overload that definition (and cause problems if users have multiple versions of Git installed). Signed-off-by: Johannes Schindelin <[email protected]> Signed-off-by: Jeff Hostetler <[email protected]>
1 parent a05b20c commit 7763928

File tree

1 file changed

+32
-2
lines changed

1 file changed

+32
-2
lines changed

fsmonitor.c

Lines changed: 32 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -254,8 +254,37 @@ void refresh_fsmonitor(struct index_state *istate)
254254
trace_printf_key(&trace_fsmonitor, "refresh fsmonitor");
255255

256256
if (fsm_mode == FSMONITOR_MODE_IPC) {
257-
/* TODO */
258-
return;
257+
query_success = !fsmonitor_ipc__send_query(
258+
istate->fsmonitor_last_update ?
259+
istate->fsmonitor_last_update : "builtin:fake",
260+
&query_result);
261+
if (query_success) {
262+
/*
263+
* The response contains a series of nul terminated
264+
* strings. The first is the new token.
265+
*
266+
* Use `char *buf` as an interlude to trick the CI
267+
* static analysis to let us use `strbuf_addstr()`
268+
* here (and only copy the token) rather than
269+
* `strbuf_addbuf()`.
270+
*/
271+
buf = query_result.buf;
272+
strbuf_addstr(&last_update_token, buf);
273+
bol = last_update_token.len + 1;
274+
} else {
275+
/*
276+
* The builtin daemon is not available on this
277+
* platform -OR- we failed to get a response.
278+
*
279+
* Generate a fake token (rather than a V1
280+
* timestamp) for the index extension. (If
281+
* they switch back to the hook API, we don't
282+
* want ambiguous state.)
283+
*/
284+
strbuf_addstr(&last_update_token, "builtin:fake");
285+
}
286+
287+
goto apply_results;
259288
}
260289

261290
assert(fsm_mode == FSMONITOR_MODE_HOOK);
@@ -321,6 +350,7 @@ void refresh_fsmonitor(struct index_state *istate)
321350
query_success ? "success" : "failure");
322351
}
323352

353+
apply_results:
324354
/*
325355
* The response from FSMonitor (excluding the header token) is
326356
* either:

0 commit comments

Comments
 (0)