]> git.ipfire.org Git - thirdparty/git.git/commitdiff
hooks: convert non-worktree 'post-checkout' hook to hook library
authorEmily Shaffer <emilyshaffer@google.com>
Wed, 22 Dec 2021 03:59:35 +0000 (04:59 +0100)
committerJunio C Hamano <gitster@pobox.com>
Fri, 7 Jan 2022 23:19:34 +0000 (15:19 -0800)
Move the running of the 'post-checkout' hook away from run-command.h
to the new hook.h library, except in the case of
builtin/worktree.c. That special-case will be handled in a subsequent
commit.

Signed-off-by: Emily Shaffer <emilyshaffer@google.com>
Signed-off-by: Ævar Arnfjörð Bjarmason <avarab@gmail.com>
Acked-by: Emily Shaffer <emilyshaffer@google.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
builtin/checkout.c
builtin/clone.c
reset.c

index 72beeb49aa90c290724cfcdfe905d67ce3224f89..e2e95445407cd3952e497b2a1afc8edc224f8589 100644 (file)
@@ -9,6 +9,7 @@
 #include "config.h"
 #include "diff.h"
 #include "dir.h"
+#include "hook.h"
 #include "ll-merge.h"
 #include "lockfile.h"
 #include "merge-recursive.h"
@@ -114,7 +115,7 @@ static void branch_info_release(struct branch_info *info)
 static int post_checkout_hook(struct commit *old_commit, struct commit *new_commit,
                              int changed)
 {
-       return run_hook_le(NULL, "post-checkout",
+       return run_hooks_l("post-checkout",
                           oid_to_hex(old_commit ? &old_commit->object.oid : null_oid()),
                           oid_to_hex(new_commit ? &new_commit->object.oid : null_oid()),
                           changed ? "1" : "0", NULL);
index fb377b27657c4048a04c85ddb82e15a950db5a7d..ee27b9f8114bd7041183e2250c80ee47b2a9c78a 100644 (file)
@@ -32,6 +32,7 @@
 #include "connected.h"
 #include "packfile.h"
 #include "list-objects-filter-options.h"
+#include "hook.h"
 
 /*
  * Overall FIXMEs:
@@ -705,7 +706,7 @@ static int checkout(int submodule_progress)
        if (write_locked_index(&the_index, &lock_file, COMMIT_LOCK))
                die(_("unable to write new index file"));
 
-       err |= run_hook_le(NULL, "post-checkout", oid_to_hex(null_oid()),
+       err |= run_hooks_l("post-checkout", oid_to_hex(null_oid()),
                           oid_to_hex(&oid), "1", NULL);
 
        if (!err && (option_recurse_submodules.nr > 0)) {
diff --git a/reset.c b/reset.c
index f214df3d96ca218a25c780b2dc79ca4ca76999de..0881e63691508c5c965620eda574d18fdd295789 100644 (file)
--- a/reset.c
+++ b/reset.c
@@ -7,6 +7,7 @@
 #include "tree-walk.h"
 #include "tree.h"
 #include "unpack-trees.h"
+#include "hook.h"
 
 int reset_head(struct repository *r, struct object_id *oid, const char *action,
               const char *switch_to_branch, unsigned flags,
@@ -127,7 +128,7 @@ reset_head_refs:
                                            reflog_head);
        }
        if (run_hook)
-               run_hook_le(NULL, "post-checkout",
+               run_hooks_l("post-checkout",
                            oid_to_hex(orig ? orig : null_oid()),
                            oid_to_hex(oid), "1", NULL);