aboutsummaryrefslogtreecommitdiff
path: root/builtin-checkout.c
diff options
context:
space:
mode:
authorStephan Beyer <s-beyer@gmx.net>2009-01-16 20:09:59 +0100
committerJunio C Hamano <gitster@pobox.com>2009-01-17 17:16:24 -0800
commitae98a0089ff7f7641ed15ddd595797de56eb49f1 (patch)
tree8f499d3252ce9c863bdca2ace275b00918b83514 /builtin-checkout.c
parent2292ce4785170d5502c4c9ea860bb73c6379f029 (diff)
downloadgit-ae98a0089ff7f7641ed15ddd595797de56eb49f1.tar.gz
git-ae98a0089ff7f7641ed15ddd595797de56eb49f1.tar.xz
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>
Diffstat (limited to 'builtin-checkout.c')
-rw-r--r--builtin-checkout.c22
1 files changed, 5 insertions, 17 deletions
diff --git a/builtin-checkout.c b/builtin-checkout.c
index 149343e3a..275176d15 100644
--- a/builtin-checkout.c
+++ b/builtin-checkout.c
@@ -38,25 +38,13 @@ struct checkout_opts {
static int post_checkout_hook(struct commit *old, struct commit *new,
int changed)
{
- struct child_process proc;
- const char *name = git_path("hooks/post-checkout");
- const char *argv[5];
-
- if (access(name, X_OK) < 0)
- return 0;
-
- memset(&proc, 0, sizeof(proc));
- argv[0] = name;
- argv[1] = sha1_to_hex(old ? old->object.sha1 : null_sha1);
- argv[2] = sha1_to_hex(new ? new->object.sha1 : null_sha1);
+ return run_hook(NULL, "post-checkout",
+ sha1_to_hex(old ? old->object.sha1 : null_sha1),
+ sha1_to_hex(new ? new->object.sha1 : null_sha1),
+ changed ? "1" : "0", NULL);
/* "new" can be NULL when checking out from the index before
a commit exists. */
- argv[3] = changed ? "1" : "0";
- argv[4] = NULL;
- proc.argv = argv;
- proc.no_stdin = 1;
- proc.stdout_to_stderr = 1;
- return run_command(&proc);
+
}
static int update_some(const unsigned char *sha1, const char *base, int baselen,