Skip to content

Commit f443246

Browse files
nasamuffingitster
authored andcommitted
commit: convert {pre-commit,prepare-commit-msg} hook to hook.h
Move these hooks hook away from run-command.h to and over to the new hook.h library. Signed-off-by: Emily Shaffer <[email protected]> Signed-off-by: Ævar Arnfjörð Bjarmason <[email protected]> Acked-by: Emily Shaffer <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent 0c8ac06 commit f443246

File tree

1 file changed

+8
-7
lines changed

1 file changed

+8
-7
lines changed

commit.c

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@
2121
#include "commit-reach.h"
2222
#include "run-command.h"
2323
#include "shallow.h"
24+
#include "hook.h"
2425

2526
static struct commit_extra_header *read_commit_extra_header_lines(const char *buf, size_t len, const char **);
2627

@@ -1702,22 +1703,22 @@ size_t ignore_non_trailer(const char *buf, size_t len)
17021703
int run_commit_hook(int editor_is_used, const char *index_file,
17031704
const char *name, ...)
17041705
{
1705-
struct strvec hook_env = STRVEC_INIT;
1706+
struct run_hooks_opt opt = RUN_HOOKS_OPT_INIT;
17061707
va_list args;
1707-
int ret;
1708+
const char *arg;
17081709

1709-
strvec_pushf(&hook_env, "GIT_INDEX_FILE=%s", index_file);
1710+
strvec_pushf(&opt.env, "GIT_INDEX_FILE=%s", index_file);
17101711

17111712
/*
17121713
* Let the hook know that no editor will be launched.
17131714
*/
17141715
if (!editor_is_used)
1715-
strvec_push(&hook_env, "GIT_EDITOR=:");
1716+
strvec_push(&opt.env, "GIT_EDITOR=:");
17161717

17171718
va_start(args, name);
1718-
ret = run_hook_ve(hook_env.v, name, args);
1719+
while ((arg = va_arg(args, const char *)))
1720+
strvec_push(&opt.args, arg);
17191721
va_end(args);
1720-
strvec_clear(&hook_env);
17211722

1722-
return ret;
1723+
return run_hooks_opt(name, &opt);
17231724
}

0 commit comments

Comments
 (0)