By using hook.h instead of run-command.h to run, post-index-change hooks can now be specified in the config in addition to the hookdir. post-index-change is not run anywhere besides in read-cache.c. Signed-off-by: Emily Shaffer <emilyshaffer@xxxxxxxxxx> --- Documentation/githooks.txt | 3 +++ read-cache.c | 14 +++++++++++--- 2 files changed, 14 insertions(+), 3 deletions(-) diff --git a/Documentation/githooks.txt b/Documentation/githooks.txt index 7ae24d65ec..5efa25a44a 100644 --- a/Documentation/githooks.txt +++ b/Documentation/githooks.txt @@ -729,6 +729,9 @@ and "0" meaning they were not. Only one parameter should be set to "1" when the hook runs. The hook running passing "1", "1" should not be possible. +Hooks run during 'post-index-change' will be run in parallel, unless hook.jobs +is configured to 1. + GIT --- Part of the linkgit:git[1] suite diff --git a/read-cache.c b/read-cache.c index 1b3c2eb408..6a5c9403f4 100644 --- a/read-cache.c +++ b/read-cache.c @@ -26,6 +26,8 @@ #include "thread-utils.h" #include "progress.h" #include "sparse-index.h" +#include "hook.h" +>>>>>>> 9524a9d29d (read-cache: convert post-index-change hook to use config) /* Mask for the name length in ce_flags in the on-disk index */ @@ -3131,6 +3133,7 @@ static int do_write_locked_index(struct index_state *istate, struct lock_file *l { int ret; int was_full = !istate->sparse_index; + struct run_hooks_opt hook_opt; ret = convert_to_sparse(istate); @@ -3159,9 +3162,14 @@ static int do_write_locked_index(struct index_state *istate, struct lock_file *l else ret = close_lock_file_gently(lock); - run_hook_le(NULL, "post-index-change", - istate->updated_workdir ? "1" : "0", - istate->updated_skipworktree ? "1" : "0", NULL); + run_hooks_opt_init_async(&hook_opt); + strvec_pushl(&hook_opt.args, + istate->updated_workdir ? "1" : "0", + istate->updated_skipworktree ? "1" : "0", + NULL); + run_hooks("post-index-change", &hook_opt); + run_hooks_opt_clear(&hook_opt); + istate->updated_workdir = 0; istate->updated_skipworktree = 0; -- 2.31.1.818.g46aad6cb9e-goog