summaryrefslogtreecommitdiff
path: root/builtin-checkout.c
diff options
context:
space:
mode:
authorJunio C Hamano <gitster@pobox.com>2009-01-21 16:50:43 -0800
committerJunio C Hamano <gitster@pobox.com>2009-01-21 16:50:43 -0800
commit1afcde6da1221bdb85a3630d995f9ca384042cb9 (patch)
tree9a010c9a301e5574aacd6d56a48e9c18d9496bb0 /builtin-checkout.c
parent35e6afd4c6bc73cba7bc279ff43b498389bf805a (diff)
parent14e6298f1215da503f0f65b63e13d674dd781868 (diff)
downloadgit-1afcde6da1221bdb85a3630d995f9ca384042cb9.tar.gz
Merge branch 'sb/hook-cleanup'
* sb/hook-cleanup: run_hook(): allow more than 9 hook arguments run_hook(): check the executability of the hook before filling argv api-run-command.txt: talk about run_hook() Move run_hook() from builtin-commit.c into run-command.c (libgit) checkout: don't crash on file checkout before running post-checkout hook
Diffstat (limited to 'builtin-checkout.c')
-rw-r--r--builtin-checkout.c22
1 files changed, 6 insertions, 16 deletions
diff --git a/builtin-checkout.c b/builtin-checkout.c
index b5dd9c07b4..275176d15d 100644
--- a/builtin-checkout.c
+++ b/builtin-checkout.c
@@ -38,23 +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];
+ 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. */
- if (access(name, X_OK) < 0)
- return 0;
-
- memset(&proc, 0, sizeof(proc));
- argv[0] = name;
- argv[1] = xstrdup(sha1_to_hex(old ? old->object.sha1 : null_sha1));
- argv[2] = xstrdup(sha1_to_hex(new->object.sha1));
- 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,