* commands: friendly-name to command map.
* event_hooks: event-name to list of friendly-names map.
* disabled_hooks: set of friendly-names with hook.<friendly-name>.enabled = false.
+ * jobs: value of the global hook.jobs key. Defaults to 0 if unset (stored in r->hook_jobs).
*/
struct hook_all_config_cb {
struct strmap commands;
struct strmap event_hooks;
struct string_list disabled_hooks;
+ unsigned int jobs;
};
/* repo_config() callback that collects all hook.* configuration in one pass. */
if (parse_config_key(key, "hook", &name, &name_len, &subkey))
return 0;
+ /* Handle plain hook.<key> entries that have no hook name component. */
+ if (!name) {
+ if (!strcmp(subkey, "jobs") && value) {
+ unsigned int v;
+ if (!git_parse_uint(value, &v))
+ warning(_("hook.jobs must be a positive integer, ignoring: '%s'"), value);
+ else if (!v)
+ warning(_("hook.jobs must be positive, ignoring: 0"));
+ else
+ data->jobs = v;
+ }
+ return 0;
+ }
+
if (!value)
return config_error_nonbool(key);
/* Populate `cache` with the complete hook configuration */
static void build_hook_config_map(struct repository *r, struct strmap *cache)
{
- struct hook_all_config_cb cb_data;
+ struct hook_all_config_cb cb_data = { 0 };
struct hashmap_iter iter;
struct strmap_entry *e;
strmap_init(&cb_data.event_hooks);
string_list_init_dup(&cb_data.disabled_hooks);
- /* Parse all configs in one run. */
+ /* Parse all configs in one run, capturing hook.* including hook.jobs. */
repo_config(r, hook_config_lookup_all, &cb_data);
/* Construct the cache from parsed configs. */
strmap_put(cache, e->key, hooks);
}
+ if (r)
+ r->hook_jobs = cb_data.jobs;
+
strmap_clear(&cb_data.commands, 1);
string_list_clear(&cb_data.disabled_hooks, 0);
strmap_for_each_entry(&cb_data.event_hooks, &iter, e) {