3 #include "run-command.h"
5 const char *find_hook(const char *name
)
7 static struct strbuf path
= STRBUF_INIT
;
10 strbuf_git_path(&path
, "hooks/%s", name
);
11 if (access(path
.buf
, X_OK
) < 0) {
14 #ifdef STRIP_EXTENSION
15 strbuf_addstr(&path
, STRIP_EXTENSION
);
16 if (access(path
.buf
, X_OK
) >= 0)
22 if (err
== EACCES
&& advice_enabled(ADVICE_IGNORED_HOOK
)) {
23 static struct string_list advise_given
= STRING_LIST_INIT_DUP
;
25 if (!string_list_lookup(&advise_given
, name
)) {
26 string_list_insert(&advise_given
, name
);
27 advise(_("The '%s' hook was ignored because "
28 "it's not set as executable.\n"
29 "You can disable this warning with "
30 "`git config advice.ignoredHook false`."),
39 int hook_exists(const char *name
)
41 return !!find_hook(name
);