| 101 | } |
| 102 | |
| 103 | static void lookup_fsmonitor_settings(struct repository *r) |
| 104 | { |
| 105 | const char *const_str; |
| 106 | char *to_free = NULL; |
| 107 | int bool_value; |
| 108 | |
| 109 | if (r->settings.fsmonitor) |
| 110 | return; |
| 111 | |
| 112 | /* |
| 113 | * Overload the existing "core.fsmonitor" config setting (which |
| 114 | * has historically been either unset or a hook pathname) to |
| 115 | * now allow a boolean value to enable the builtin FSMonitor |
| 116 | * or to turn everything off. (This does imply that you can't |
| 117 | * use a hook script named "true" or "false", but that's OK.) |
| 118 | */ |
| 119 | switch (repo_config_get_maybe_bool(r, "core.fsmonitor", &bool_value)) { |
| 120 | |
| 121 | case 0: /* config value was set to <bool> */ |
| 122 | if (bool_value) |
| 123 | fsm_settings__set_ipc(r); |
| 124 | else |
| 125 | fsm_settings__set_disabled(r); |
| 126 | return; |
| 127 | |
| 128 | case 1: /* config value was unset */ |
| 129 | const_str = getenv("GIT_TEST_FSMONITOR"); |
| 130 | break; |
| 131 | |
| 132 | case -1: /* config value set to an arbitrary string */ |
| 133 | if (repo_config_get_pathname(r, "core.fsmonitor", &to_free)) |
| 134 | return; /* should not happen */ |
| 135 | const_str = to_free; |
| 136 | break; |
| 137 | |
| 138 | default: /* should not happen */ |
| 139 | return; |
| 140 | } |
| 141 | |
| 142 | if (const_str && *const_str) |
| 143 | fsm_settings__set_hook(r, const_str); |
| 144 | else |
| 145 | fsm_settings__set_disabled(r); |
| 146 | free(to_free); |
| 147 | } |
| 148 | |
| 149 | enum fsmonitor_mode fsm_settings__get_mode(struct repository *r) |
| 150 | { |
no test coverage detected