9 /* Environment vars to be set for each hook */
12 /* Args to be passed to each hook */
15 /* Emit an error if the hook is missing */
16 unsigned int error_if_missing
:1;
19 * An optional initial working directory for the hook,
20 * translates to "struct child_process"'s "dir" member.
25 * A pointer which if provided will be set to 1 or 0 depending
26 * on if a hook was started, regardless of whether or not that
27 * was successful. I.e. if the underlying start_command() was
28 * successful this will be set to 1.
30 * Used for avoiding TOCTOU races in code that would otherwise
31 * call hook_exist() after a "maybe hook run" to see if a hook
37 * Path to file which should be piped to stdin for each hook.
39 const char *path_to_stdin
;
42 #define RUN_HOOKS_OPT_INIT { \
44 .args = STRVEC_INIT, \
48 /* rc reflects the cumulative failure state */
50 const char *hook_name
;
51 const char *hook_path
;
52 struct run_hooks_opt
*options
;
56 * Returns the path to the hook file, or NULL if the hook is missing
57 * or disabled. Note that this points to static storage that will be
58 * overwritten by further calls to find_hook and run_hook_*.
60 const char *find_hook(struct repository
*r
, const char *name
);
63 * A boolean version of find_hook()
65 int hook_exists(struct repository
*r
, const char *hookname
);
68 * Takes a `hook_name`, resolves it to a path with find_hook(), and
69 * runs the hook for you with the options specified in "struct
70 * run_hooks opt". Will free memory associated with the "struct run_hooks_opt".
72 * Returns the status code of the run hook, or a negative value on
75 int run_hooks_opt(struct repository
*r
, const char *hook_name
,
76 struct run_hooks_opt
*options
);
79 * A wrapper for run_hooks_opt() which provides a dummy "struct
80 * run_hooks_opt" initialized with "RUN_HOOKS_OPT_INIT".
82 int run_hooks(struct repository
*r
, const char *hook_name
);
85 * Like run_hooks(), a wrapper for run_hooks_opt().
87 * In addition to the wrapping behavior provided by run_hooks(), this
88 * wrapper takes a list of strings terminated by a NULL
89 * argument. These things will be used as positional arguments to the
90 * hook. This function behaves like the old run_hook_le() API.
93 int run_hooks_l(struct repository
*r
, const char *hook_name
, ...);