From: Jonathan Tan Date: Wed, 23 Sep 2020 23:20:31 GMT Subject: Re: [PATCH v4 7/9] hook: replace run-command.h:find_hook Message-ID: <20200923232031.1283731-1-jonathantanmy@google.com> In-Reply-To: <20200909004939.1942347-8-emilyshaffer@google.com> > +int hook_exists(const char *hookname) > +{ > + const char *value = NULL; > + struct strbuf hook_key = STRBUF_INIT; > + strbuf_addf(&hook_key, "hook.%s.command", hookname); > + > + return (!git_config_get_value(hook_key.buf, &value)) || !!find_hook(hookname); > +} I was surprised that this didn't share code with hook_list. Upon further thought, hook_list might be expensive if hooks are present, but if we can cache results, I think it's worth it. A caller that calls this function usually will run hooks if they are present, so it's not wasted work to construct the hook list.