aboutsummaryrefslogtreecommitdiffstats
path: root/hook.c
diff options
context:
space:
mode:
authorJunio C Hamano <gitster@pobox.com>2022-03-16 17:53:09 -0700
committerJunio C Hamano <gitster@pobox.com>2022-03-16 17:53:09 -0700
commit7431379a9c5ed4006603114b1991c6c6e98d5dca (patch)
treefcc981d9556302ae47199fa9cc7c932ccd157bdc /hook.c
parentMerge branch 'ab/keep-git-exit-codes-in-tests' (diff)
parenthooks: fix an obscure TOCTOU "did we just run a hook?" race (diff)
downloadgit-7431379a9c5ed4006603114b1991c6c6e98d5dca.tar.gz
git-7431379a9c5ed4006603114b1991c6c6e98d5dca.zip
Merge branch 'ab/racy-hooks'
Code clean-up to allow callers of run_commit_hook() to learn if it got "success" because the hook succeeded or because there wasn't any hook. * ab/racy-hooks: hooks: fix an obscure TOCTOU "did we just run a hook?" race merge: don't run post-hook logic on --no-verify
Diffstat (limited to 'hook.c')
-rw-r--r--hook.c7
1 files changed, 7 insertions, 0 deletions
diff --git a/hook.c b/hook.c
index 69a215b2c3..1d51be3b77 100644
--- a/hook.c
+++ b/hook.c
@@ -96,9 +96,13 @@ static int notify_hook_finished(int result,
void *pp_task_cb)
{
struct hook_cb_data *hook_cb = pp_cb;
+ struct run_hooks_opt *opt = hook_cb->options;
hook_cb->rc |= result;
+ if (opt->invoked_hook)
+ *opt->invoked_hook = 1;
+
return 0;
}
@@ -123,6 +127,9 @@ int run_hooks_opt(const char *hook_name, struct run_hooks_opt *options)
if (!options)
BUG("a struct run_hooks_opt must be provided to run_hooks");
+ if (options->invoked_hook)
+ *options->invoked_hook = 0;
+
if (!hook_path && !options->error_if_missing)
goto cleanup;