From 1a3017d908824ab42ca7a5af7073f4cdc5c88fbf Mon Sep 17 00:00:00 2001 From: Emily Shaffer Date: Wed, 22 Dec 2021 04:59:36 +0100 Subject: hooks: convert worktree 'post-checkout' hook to hook library MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Move the running of the 'post-checkout' hook away from run-command.h to the new hook.h library in builtin/worktree.c. For this special case we need a change to the hook API to teach it to run the hook from a given directory. We cannot skip the "absolute_path" flag and just check if "dir" is specified as we'd then fail to find our hook in the new dir we'd chdir() to. We currently don't have a use-case for running a hook not in our "base" repository at a given absolute path, so let's have "dir" imply absolute_path(find_hook(hook_name)). Signed-off-by: Emily Shaffer Signed-off-by: Ævar Arnfjörð Bjarmason Acked-by: Emily Shaffer Signed-off-by: Junio C Hamano --- hook.h | 6 ++++++ 1 file changed, 6 insertions(+) (limited to 'hook.h') diff --git a/hook.h b/hook.h index 5452839595..18d90aedf1 100644 --- a/hook.h +++ b/hook.h @@ -12,6 +12,12 @@ struct run_hooks_opt /* Emit an error if the hook is missing */ unsigned int error_if_missing:1; + + /** + * An optional initial working directory for the hook, + * translates to "struct child_process"'s "dir" member. + */ + const char *dir; }; #define RUN_HOOKS_OPT_INIT { \ -- cgit v1.2.3