diff options
| author | Jiang Xin <worldhello.net@gmail.com> | 2026-04-04 11:53:49 +0800 |
|---|---|---|
| committer | Jiang Xin <worldhello.net@gmail.com> | 2026-04-04 11:57:24 +0800 |
| commit | fc2a6741f71c71ddc7e1cc71c8f6289fcda2ff2d (patch) | |
| tree | baec3af2039bd59c01e049f3bd9e10e233d44a1d /hook.h | |
| parent | 82747b07cc0f7d6fd8237633c1eb533050efba3d (diff) | |
| parent | 8de2f1b07a8053d7f1aad70dc1131d6afcf5a28a (diff) | |
| download | git-fc2a6741f71c71ddc7e1cc71c8f6289fcda2ff2d.tar.gz git-fc2a6741f71c71ddc7e1cc71c8f6289fcda2ff2d.zip | |
Merge branch 'master' of https://github.com/git/git
Upstream adds 18 new translatable messages.
* 'master' of https://github.com/git/git: (41 commits)
A bit more on top of 2.54-rc0
...
Signed-off-by: Jiang Xin <worldhello.net@gmail.com>
Diffstat (limited to 'hook.h')
| -rw-r--r-- | hook.h | 34 |
1 files changed, 22 insertions, 12 deletions
@@ -1,17 +1,21 @@ #ifndef HOOK_H #define HOOK_H -#include "strvec.h" +#include "config.h" #include "run-command.h" #include "string-list.h" #include "strmap.h" +#include "strvec.h" struct repository; +typedef void (*hook_data_free_fn)(void *data); +typedef void *(*hook_data_alloc_fn)(void *init_ctx); + /** * Represents a hook command to be run. * Hooks can be: * 1. "traditional" (found in the hooks directory) - * 2. "configured" (defined in Git's configuration via hook.<name>.event). + * 2. "configured" (defined in Git's configuration via hook.<friendly-name>.event). * The 'kind' field determines which part of the union 'u' is valid. */ struct hook { @@ -26,6 +30,8 @@ struct hook { struct { const char *friendly_name; const char *command; + enum config_scope scope; + bool disabled; } configured; } u; @@ -41,13 +47,17 @@ struct hook { * Only useful when using `run_hooks_opt.feed_pipe`, otherwise ignore it. */ void *feed_pipe_cb_data; -}; -typedef void (*cb_data_free_fn)(void *data); -typedef void *(*cb_data_alloc_fn)(void *init_ctx); + /** + * Callback to free `feed_pipe_cb_data`. + * + * It is called automatically and points to the `feed_pipe_cb_data_free` + * provided via the `run_hook_opt` parameter. + */ + hook_data_free_fn data_free; +}; -struct run_hooks_opt -{ +struct run_hooks_opt { /* Environment vars to be set for each hook */ struct strvec env; @@ -132,14 +142,14 @@ struct run_hooks_opt * * The `feed_pipe_ctx` pointer can be used to pass initialization data. */ - cb_data_alloc_fn feed_pipe_cb_data_alloc; + hook_data_alloc_fn feed_pipe_cb_data_alloc; /** * Called to free the memory initialized by `feed_pipe_cb_data_alloc`. * * Must always be provided when `feed_pipe_cb_data_alloc` is provided. */ - cb_data_free_fn feed_pipe_cb_data_free; + hook_data_free_fn feed_pipe_cb_data_free; }; #define RUN_HOOKS_OPT_INIT { \ @@ -186,10 +196,10 @@ struct string_list *list_hooks(struct repository *r, const char *hookname, struct run_hooks_opt *options); /** - * Frees the memory allocated for the hook list, including the `struct hook` - * items and their internal state. + * Frees a struct hook stored as the util pointer of a string_list_item. + * Suitable for use as a string_list_clear_func_t callback. */ -void hook_list_clear(struct string_list *hooks, cb_data_free_fn cb_data_free); +void hook_free(void *p, const char *str); /** * Frees the hook configuration cache stored in `struct repository`. |
