aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--hook.c7
-rw-r--r--hook.h9
2 files changed, 14 insertions, 2 deletions
diff --git a/hook.c b/hook.c
index fde1f88ce8..cde7198412 100644
--- a/hook.c
+++ b/hook.c
@@ -152,8 +152,8 @@ int run_hooks_opt(struct repository *r, const char *hook_name,
.tr2_category = "hook",
.tr2_label = hook_name,
- .processes = 1,
- .ungroup = 1,
+ .processes = options->jobs,
+ .ungroup = options->jobs == 1,
.get_next_task = pick_next_hook,
.start_failure = notify_start_failure,
@@ -169,6 +169,9 @@ int run_hooks_opt(struct repository *r, const char *hook_name,
if (options->path_to_stdin && options->feed_pipe)
BUG("options path_to_stdin and feed_pipe are mutually exclusive");
+ if (!options->jobs)
+ BUG("run_hooks_opt must be called with options.jobs >= 1");
+
if (options->invoked_hook)
*options->invoked_hook = 0;
diff --git a/hook.h b/hook.h
index 2c8a23a569..20eb56fd63 100644
--- a/hook.h
+++ b/hook.h
@@ -17,6 +17,14 @@ struct run_hooks_opt
unsigned int error_if_missing:1;
/**
+ * Number of processes to parallelize across.
+ *
+ * If > 1, output will be buffered and de-interleaved (ungroup=0).
+ * If == 1, output will be real-time (ungroup=1).
+ */
+ unsigned int jobs;
+
+ /**
* An optional initial working directory for the hook,
* translates to "struct child_process"'s "dir" member.
*/
@@ -90,6 +98,7 @@ struct run_hooks_opt
.env = STRVEC_INIT, \
.args = STRVEC_INIT, \
.stdout_to_stderr = 1, \
+ .jobs = 1, \
}
struct hook_cb_data {