182
char ref_name[FLEX_ARRAY]; /* more */
183
};
184
185
-static const char pre_receive_hook[] = "hooks/pre-receive";
186
-static const char post_receive_hook[] = "hooks/post-receive";
187
-
185
static void rp_error(const char *err, ...) __attribute__((format (printf, 1, 2)));
186
static void rp_warning(const char *err, ...) __attribute__((format (printf, 1, 2)));
187
239
const char *argv[2];
240
int code;
241
245
- if (access(hook_name, X_OK) < 0)
242
+ argv[0] = find_hook(hook_name);
243
+ if (!argv[0])
244
return 0;
245
248
- argv[0] = hook_name;
246
argv[1] = NULL;
247
248
memset(&proc, 0, sizeof(proc));
328
329
static int run_update_hook(struct command *cmd)
330
{
334
- static const char update_hook[] = "hooks/update";
331
const char *argv[5];
332
struct child_process proc;
333
int code;
334
339
- if (access(update_hook, X_OK) < 0)
335
+ argv[0] = find_hook("update");
336
+ if (!argv[0])
337
return 0;
338
342
- argv[0] = update_hook;
339
argv[1] = cmd->ref_name;
340
argv[2] = sha1_to_hex(cmd->old_sha1);
341
argv[3] = sha1_to_hex(cmd->new_sha1);
528
}
529
}
530
535
-static char update_post_hook[] = "hooks/post-update";
536
-
531
static void run_update_post_hook(struct command *commands)
532
{
533
struct command *cmd;
534
int argc;
535
const char **argv;
536
struct child_process proc;
537
+ char *hook;
538
539
+ hook = find_hook("post-update");
540
for (argc = 0, cmd = commands; cmd; cmd = cmd->next) {
541
if (cmd->error_string || cmd->did_not_exist)
542
continue;
543
argc++;
544
}
549
- if (!argc || access(update_post_hook, X_OK) < 0)
545
+ if (!argc || !hook)
546
return;
547
+
548
argv = xmalloc(sizeof(*argv) * (2 + argc));
552
- argv[0] = update_post_hook;
549
+ argv[0] = hook;
550
551
for (argc = 1, cmd = commands; cmd; cmd = cmd->next) {
552
char *p;
701
0, &cmd))
702
set_connectivity_errors(commands);
703
707
- if (run_receive_hook(commands, pre_receive_hook, 0)) {
704
+ if (run_receive_hook(commands, "pre-receive", 0)) {
705
for (cmd = commands; cmd; cmd = cmd->next) {
706
if (!cmd->error_string)
707
cmd->error_string = "pre-receive hook declined";
991
unlink_or_warn(pack_lockfile);
992
if (report_status)
993
report(commands, unpack_status);
997
- run_receive_hook(commands, post_receive_hook, 1);
994
+ run_receive_hook(commands, "post-receive", 1);
995
run_update_post_hook(commands);
996
if (auto_gc) {
997
const char *argv_gc_auto[] = {