* Call the query-fsmonitor hook passing the last update token of the saved results. */
| 157 | * Call the query-fsmonitor hook passing the last update token of the saved results. |
| 158 | */ |
| 159 | static int query_fsmonitor_hook(struct repository *r, |
| 160 | int version, |
| 161 | const char *last_update, |
| 162 | struct strbuf *query_result) |
| 163 | { |
| 164 | struct child_process cp = CHILD_PROCESS_INIT; |
| 165 | int result; |
| 166 | |
| 167 | if (fsm_settings__get_mode(r) != FSMONITOR_MODE_HOOK) |
| 168 | return -1; |
| 169 | |
| 170 | strvec_push(&cp.args, fsm_settings__get_hook_path(r)); |
| 171 | strvec_pushf(&cp.args, "%d", version); |
| 172 | strvec_pushf(&cp.args, "%s", last_update); |
| 173 | cp.use_shell = 1; |
| 174 | cp.dir = repo_get_work_tree(the_repository); |
| 175 | |
| 176 | trace2_region_enter("fsm_hook", "query", NULL); |
| 177 | |
| 178 | result = capture_command(&cp, query_result, 1024); |
| 179 | |
| 180 | if (result) |
| 181 | trace2_data_intmax("fsm_hook", NULL, "query/failed", result); |
| 182 | else |
| 183 | trace2_data_intmax("fsm_hook", NULL, "query/response-length", |
| 184 | query_result->len); |
| 185 | |
| 186 | trace2_region_leave("fsm_hook", "query", NULL); |
| 187 | |
| 188 | return result; |
| 189 | } |
| 190 | |
| 191 | /* |
| 192 | * Invalidate the FSM bit on this CE. This is like mark_fsmonitor_invalid() |
no test coverage detected