Merge branch 'ab/config-based-hooks-2'
More "config-based hooks".
* ab/config-based-hooks-2:
run-command: remove old run_hook_{le,ve}() hook API
receive-pack: convert push-to-checkout hook to hook.h
read-cache: convert post-index-change to use hook.h
commit: convert {pre-commit,prepare-commit-msg} hook to hook.h
git-p4: use 'git hook' to run hooks
send-email: use 'git hook run' for 'sendemail-validate'
git hook run: add an --ignore-missing flag
hooks: convert worktree 'post-checkout' hook to hook library
hooks: convert non-worktree 'post-checkout' hook to hook library
merge: convert post-merge to use hook.h
am: convert applypatch-msg to use hook.h
rebase: convert pre-rebase to use hook.h
hook API: add a run_hooks_l() wrapper
am: convert {pre,post}-applypatch to use hook.h
gc: use hook library for pre-auto-gc hook
hook API: add a run_hooks() wrapper
hook: add 'run' subcommand
This commit is contained in:
15
commit.c
15
commit.c
@ -21,6 +21,7 @@
|
||||
#include "commit-reach.h"
|
||||
#include "run-command.h"
|
||||
#include "shallow.h"
|
||||
#include "hook.h"
|
||||
|
||||
static struct commit_extra_header *read_commit_extra_header_lines(const char *buf, size_t len, const char **);
|
||||
|
||||
@ -1714,22 +1715,22 @@ size_t ignore_non_trailer(const char *buf, size_t len)
|
||||
int run_commit_hook(int editor_is_used, const char *index_file,
|
||||
const char *name, ...)
|
||||
{
|
||||
struct strvec hook_env = STRVEC_INIT;
|
||||
struct run_hooks_opt opt = RUN_HOOKS_OPT_INIT;
|
||||
va_list args;
|
||||
int ret;
|
||||
const char *arg;
|
||||
|
||||
strvec_pushf(&hook_env, "GIT_INDEX_FILE=%s", index_file);
|
||||
strvec_pushf(&opt.env, "GIT_INDEX_FILE=%s", index_file);
|
||||
|
||||
/*
|
||||
* Let the hook know that no editor will be launched.
|
||||
*/
|
||||
if (!editor_is_used)
|
||||
strvec_push(&hook_env, "GIT_EDITOR=:");
|
||||
strvec_push(&opt.env, "GIT_EDITOR=:");
|
||||
|
||||
va_start(args, name);
|
||||
ret = run_hook_ve(hook_env.v, name, args);
|
||||
while ((arg = va_arg(args, const char *)))
|
||||
strvec_push(&opt.args, arg);
|
||||
va_end(args);
|
||||
strvec_clear(&hook_env);
|
||||
|
||||
return ret;
|
||||
return run_hooks_opt(name, &opt);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user