diff options
author | Junio C Hamano <gitster@pobox.com> | 2013-01-24 05:19:25 (GMT) |
---|---|---|
committer | Junio C Hamano <gitster@pobox.com> | 2013-01-24 05:19:25 (GMT) |
commit | bb9a69694f27aa299777c679979f75bdef75735d (patch) | |
tree | f00e9f412cd91c4f2b5aa355d68bc0b501ff8ee3 /run-command.c | |
parent | 86db7464496ca82488071c7a9e7e57eff07cd900 (diff) | |
parent | 87c86dd14abe8db7d00b0df5661ef8cf147a72a3 (diff) | |
download | git-bb9a69694f27aa299777c679979f75bdef75735d.zip git-bb9a69694f27aa299777c679979f75bdef75735d.tar.gz git-bb9a69694f27aa299777c679979f75bdef75735d.tar.bz2 |
Merge branch 'as/pre-push-hook'
Add an extra hook so that "git push" that is run without making
sure what is being pushed is sane can be checked and rejected (as
opposed to the user deciding not pushing).
* as/pre-push-hook:
Add sample pre-push hook script
push: Add support for pre-push hooks
hooks: Add function to check if a hook exists
Diffstat (limited to 'run-command.c')
-rw-r--r-- | run-command.c | 15 |
1 files changed, 13 insertions, 2 deletions
diff --git a/run-command.c b/run-command.c index 0471219..12d4ddb 100644 --- a/run-command.c +++ b/run-command.c @@ -735,6 +735,15 @@ int finish_async(struct async *async) #endif } +char *find_hook(const char *name) +{ + char *path = git_path("hooks/%s", name); + if (access(path, X_OK) < 0) + path = NULL; + + return path; +} + int run_hook(const char *index_file, const char *name, ...) { struct child_process hook; @@ -744,11 +753,13 @@ int run_hook(const char *index_file, const char *name, ...) va_list args; int ret; - if (access(git_path("hooks/%s", name), X_OK) < 0) + p = find_hook(name); + if (!p) return 0; + argv_array_push(&argv, p); + va_start(args, name); - argv_array_push(&argv, git_path("hooks/%s", name)); while ((p = va_arg(args, const char *))) argv_array_push(&argv, p); va_end(args); |