hook.c users: use "hook_exists()" instead of "find_hook()"
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>
Ævar Arnfjörð Bjarmason committed
Sep 26, 2021 at 21:03 UTC
07a348e7461afe9411004a0501034cb3ff1cdee8
4 files changed
+4
-4
builtin/commit.c
+1
-1
@@ -1052,7 +1052,7 @@ static int prepare_to_commit(const char *index_file, const char *prefix,
1052
return 0;
1053
}
1054
1055
- if (!no_verify && find_hook("pre-commit")) {
1055
+ if (!no_verify && hook_exists("pre-commit")) {
1056
/*
1057
* Re-read the index as pre-commit hook could have updated it,
1058
* and write it out as a tree. We must do this before we invoke
builtin/merge.c
+1
-1
@@ -849,7 +849,7 @@ static void prepare_to_commit(struct commit_list *remoteheads)
849
* and write it out as a tree. We must do this before we invoke
850
* the editor and after we invoke run_status above.
851
*/
852
- if (find_hook("pre-merge-commit"))
852
+ if (hook_exists("pre-merge-commit"))
853
discard_cache();
854
read_cache_from(index_file);
855
strbuf_addbuf(&msg, &merge_msg);
builtin/receive-pack.c
+1
-1
@@ -1464,7 +1464,7 @@ static const char *update_worktree(unsigned char *sha1, const struct worktree *w
1464
1465
strvec_pushf(&env, "GIT_DIR=%s", absolute_path(git_dir));
1466
1467
- if (!find_hook(push_to_checkout_hook))
1467
+ if (!hook_exists(push_to_checkout_hook))
1468
retval = push_to_deploy(sha1, &env, work_tree);
1469
else
1470
retval = push_to_checkout(sha1, &env, work_tree);
sequencer.c
+1
-1
@@ -1460,7 +1460,7 @@ static int try_to_commit(struct repository *r,
1460
}
1461
}
1462
1463
- if (find_hook("prepare-commit-msg")) {
1463
+ if (hook_exists("prepare-commit-msg")) {
1464
res = run_prepare_commit_msg_hook(r, msg, hook_commit);
1465
if (res)
1466
goto out;