Skip to content

Commit 07a348e

Browse files
avargitster
authored andcommitted
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 <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent 330155e commit 07a348e

File tree

4 files changed

+4
-4
lines changed

4 files changed

+4
-4
lines changed

builtin/commit.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1052,7 +1052,7 @@ static int prepare_to_commit(const char *index_file, const char *prefix,
10521052
return 0;
10531053
}
10541054

1055-
if (!no_verify && find_hook("pre-commit")) {
1055+
if (!no_verify && hook_exists("pre-commit")) {
10561056
/*
10571057
* Re-read the index as pre-commit hook could have updated it,
10581058
* and write it out as a tree. We must do this before we invoke

builtin/merge.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -849,7 +849,7 @@ static void prepare_to_commit(struct commit_list *remoteheads)
849849
* and write it out as a tree. We must do this before we invoke
850850
* the editor and after we invoke run_status above.
851851
*/
852-
if (find_hook("pre-merge-commit"))
852+
if (hook_exists("pre-merge-commit"))
853853
discard_cache();
854854
read_cache_from(index_file);
855855
strbuf_addbuf(&msg, &merge_msg);

builtin/receive-pack.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1464,7 +1464,7 @@ static const char *update_worktree(unsigned char *sha1, const struct worktree *w
14641464

14651465
strvec_pushf(&env, "GIT_DIR=%s", absolute_path(git_dir));
14661466

1467-
if (!find_hook(push_to_checkout_hook))
1467+
if (!hook_exists(push_to_checkout_hook))
14681468
retval = push_to_deploy(sha1, &env, work_tree);
14691469
else
14701470
retval = push_to_checkout(sha1, &env, work_tree);

sequencer.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1460,7 +1460,7 @@ static int try_to_commit(struct repository *r,
14601460
}
14611461
}
14621462

1463-
if (find_hook("prepare-commit-msg")) {
1463+
if (hook_exists("prepare-commit-msg")) {
14641464
res = run_prepare_commit_msg_hook(r, msg, hook_commit);
14651465
if (res)
14661466
goto out;

0 commit comments

Comments
 (0)