X-Git-Url: http://git.ipfire.org/?a=blobdiff_plain;f=commit.c;h=52036bc90fa5fdcc4826d79a92837b6dae4a20bc;hb=13c4d7eb228ea29dba77f8800daf2bd0ac54755a;hp=40890ae7ce8a48a2da06bcde6fc5a9db77260707;hpb=1f4485b2194f662d82968bd6110fa63153df5298;p=thirdparty%2Fgit.git diff --git a/commit.c b/commit.c index 40890ae7ce..52036bc90f 100644 --- a/commit.c +++ b/commit.c @@ -19,6 +19,7 @@ #include "advice.h" #include "refs.h" #include "commit-reach.h" +#include "run-command.h" static struct commit_extra_header *read_commit_extra_header_lines(const char *buf, size_t len, const char **); @@ -1581,3 +1582,26 @@ size_t ignore_non_trailer(const char *buf, size_t len) } return boc ? len - boc : len - cutoff; } + +int run_commit_hook(int editor_is_used, const char *index_file, + const char *name, ...) +{ + struct argv_array hook_env = ARGV_ARRAY_INIT; + va_list args; + int ret; + + argv_array_pushf(&hook_env, "GIT_INDEX_FILE=%s", index_file); + + /* + * Let the hook know that no editor will be launched. + */ + if (!editor_is_used) + argv_array_push(&hook_env, "GIT_EDITOR=:"); + + va_start(args, name); + ret = run_hook_ve(hook_env.argv,name, args); + va_end(args); + argv_array_clear(&hook_env); + + return ret; +}