Move run_hook() from builtin-commit.c into run-command.c (libgit)

A function that runs a hook is used in several Git commands.
builtin-commit.c has the one that is most general for cases without
piping. The one in builtin-gc.c prints some useful warnings.
This patch moves a merged version of these variants into libgit and
lets the other builtins use this libified run_hook().

The run_hook() function used in receive-pack.c feeds the standard
input of the pre-receive or post-receive hooks. This function is
renamed to run_receive_hook() because the libified run_hook() cannot
handle this.

Mentored-by: Daniel Barkalow <barkalow@iabervon.org>
Mentored-by: Christian Couder <chriscool@tuxfamily.org>
Signed-off-by: Stephan Beyer <s-beyer@gmx.net>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
This commit is contained in:
Stephan Beyer
2009-01-16 20:09:59 +01:00
committed by Junio C Hamano
parent 2292ce4785
commit ae98a0089f
7 changed files with 57 additions and 113 deletions

View File

@ -136,7 +136,7 @@ static int hook_status(int code, const char *hook_name)
}
}
static int run_hook(const char *hook_name)
static int run_receive_hook(const char *hook_name)
{
static char buf[sizeof(commands->old_sha1) * 2 + PATH_MAX + 4];
struct command *cmd;
@ -358,7 +358,7 @@ static void execute_commands(const char *unpacker_error)
return;
}
if (run_hook(pre_receive_hook)) {
if (run_receive_hook(pre_receive_hook)) {
while (cmd) {
cmd->error_string = "pre-receive hook declined";
cmd = cmd->next;
@ -627,7 +627,7 @@ int cmd_receive_pack(int argc, const char **argv, const char *prefix)
unlink(pack_lockfile);
if (report_status)
report(unpack_status);
run_hook(post_receive_hook);
run_receive_hook(post_receive_hook);
run_update_post_hook(commands);
}
return 0;