]> git.ipfire.org Git - thirdparty/git.git/commitdiff
hook.c users: use "hook_exists()" instead of "find_hook()"
authorÆvar Arnfjörð Bjarmason <avarab@gmail.com>
Sun, 26 Sep 2021 19:03:28 +0000 (21:03 +0200)
committerJunio C Hamano <gitster@pobox.com>
Mon, 27 Sep 2021 16:44:54 +0000 (09:44 -0700)
Use the new hook_exists() function instead of find_hook() where the
latter was called in boolean contexts. This make subsequent changes in
a series where we further refactor the hook API clearer, as we won't
conflate wanting to get the path of the hook with checking for its
existence.

Signed-off-by: Ævar Arnfjörð Bjarmason <avarab@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
builtin/commit.c
builtin/merge.c
builtin/receive-pack.c
sequencer.c

index 5359d961d228dddec6b05a4bbeacea44d81e8477..883c16256c87f75c8367573ba42a8ee8e04346a7 100644 (file)
@@ -1052,7 +1052,7 @@ static int prepare_to_commit(const char *index_file, const char *prefix,
                return 0;
        }
 
-       if (!no_verify && find_hook("pre-commit")) {
+       if (!no_verify && hook_exists("pre-commit")) {
                /*
                 * Re-read the index as pre-commit hook could have updated it,
                 * and write it out as a tree.  We must do this before we invoke
index fe664f6a863d56993bd7a6608c7cf55b53cfa169..956b6259f21ec06141d8ca7f4b586e07d631a651 100644 (file)
@@ -849,7 +849,7 @@ static void prepare_to_commit(struct commit_list *remoteheads)
         * and write it out as a tree.  We must do this before we invoke
         * the editor and after we invoke run_status above.
         */
-       if (find_hook("pre-merge-commit"))
+       if (hook_exists("pre-merge-commit"))
                discard_cache();
        read_cache_from(index_file);
        strbuf_addbuf(&msg, &merge_msg);
index e3895aec622ea2988b944ec928ef6bf022680eb4..25cc0c907e133650ed55d173353155d35df33f89 100644 (file)
@@ -1464,7 +1464,7 @@ static const char *update_worktree(unsigned char *sha1, const struct worktree *w
 
        strvec_pushf(&env, "GIT_DIR=%s", absolute_path(git_dir));
 
-       if (!find_hook(push_to_checkout_hook))
+       if (!hook_exists(push_to_checkout_hook))
                retval = push_to_deploy(sha1, &env, work_tree);
        else
                retval = push_to_checkout(sha1, &env, work_tree);
index 8ee6c4ac24006e82b973036df1bac1db7fdd502c..e501945796d792d741d06d867aea2fce357397bf 100644 (file)
@@ -1460,7 +1460,7 @@ static int try_to_commit(struct repository *r,
                }
        }
 
-       if (find_hook("prepare-commit-msg")) {
+       if (hook_exists("prepare-commit-msg")) {
                res = run_prepare_commit_msg_hook(r, msg, hook_commit);
                if (res)
                        goto out;