aboutsummaryrefslogtreecommitdiffstats
path: root/hook.h
diff options
context:
space:
mode:
authorJunio C Hamano <gitster@pobox.com>2025-11-08 10:33:20 -0800
committerJunio C Hamano <gitster@pobox.com>2025-11-08 10:33:20 -0800
commit0cea3ad7186bbdc21864fbabfd19cdf3ae08d9cb (patch)
tree78d0640d85537aff27695bc0ab88610cfbdc4014 /hook.h
parentMerge branch 'en/xdiff-cleanup-2' into seen (diff)
parentreceive-pack: convert receive hooks to hook API (diff)
downloadgit-0cea3ad7186bbdc21864fbabfd19cdf3ae08d9cb.tar.gz
git-0cea3ad7186bbdc21864fbabfd19cdf3ae08d9cb.zip
Merge branch 'ar/run-command-hook' into seen
Use hook API to replace ad-hoc invocation of hook scripts with the run_command() API. Comments? * ar/run-command-hook: receive-pack: convert receive hooks to hook API receive-pack: convert update hooks to new API hooks: allow callers to capture output run-command: allow capturing of collated output reference-transaction: use hook API instead of run-command hook: allow overriding the ungroup option transport: convert pre-push to hook API hook: convert 'post-rewrite' hook in sequencer.c to hook API hook: provide stdin via callback run-command: add stdin callback for parallelization
Diffstat (limited to 'hook.h')
-rw-r--r--hook.h36
1 files changed, 36 insertions, 0 deletions
diff --git a/hook.h b/hook.h
index 11863fa734..a84e97db34 100644
--- a/hook.h
+++ b/hook.h
@@ -1,6 +1,7 @@
#ifndef HOOK_H
#define HOOK_H
#include "strvec.h"
+#include "run-command.h"
struct repository;
@@ -34,9 +35,44 @@ struct run_hooks_opt
int *invoked_hook;
/**
+ * Allow hooks to set run_processes_parallel() 'ungroup' behavior.
+ */
+ unsigned int ungroup:1;
+
+ /**
* Path to file which should be piped to stdin for each hook.
*/
const char *path_to_stdin;
+
+ /**
+ * Callback to ask for more content to pipe to each hook stdin.
+ *
+ * If a hook needs to consume large quantities of data (e.g. a
+ * list of all refs received in a client push), feeding data via
+ * in-memory strings or slurping to/from files via path_to_stdin
+ * is inefficient, so this callback allows for piecemeal writes.
+ *
+ * Add initalization context to hook.feed_pipe_ctx.
+ *
+ * The caller owns hook.feed_pipe_ctx and has to release any
+ * resources after hooks finish execution.
+ */
+ feed_pipe_fn feed_pipe;
+ void *feed_pipe_ctx;
+
+ /**
+ * Use this to keep internal state for your feed_pipe_fn callback.
+ * Only useful when using run_hooks_opt.feed_pipe, otherwise ignore it.
+ */
+ void *feed_pipe_cb_data;
+
+ /*
+ * Populate this to capture output and prevent it from being printed to
+ * stderr. This will be passed directly through to
+ * run_command:run_parallel_processes(). See t/helper/test-run-command.c
+ * for an example.
+ */
+ consume_sideband_fn consume_sideband;
};
#define RUN_HOOKS_OPT_INIT { \