path: root/run-command.c
diff options
authorÆvar Arnfjörð Bjarmason <>2016-05-04 22:58:12 (GMT)
committerJunio C Hamano <>2016-05-04 23:25:13 (GMT)
commit867ad08a2610526edb5723804723d371136fc643 (patch)
tree32abb4c13d2fd68c692408299aeb6ba566a359c4 /run-command.c
parentde0824ed8fa3319cfdc0c79c06c06d7c72c6adc6 (diff)
hooks: allow customizing where the hook directory is
Change the hardcoded lookup for .git/hooks/* to optionally lookup in $(git config core.hooksPath)/* instead. This is essentially a more intrusive version of the git-init ability to specify hooks on init time via init templates. The difference between that facility and this feature is that this can be set up after the fact via e.g. ~/.gitconfig or /etc/gitconfig to apply for all your personal repositories, or all repositories on the system. I plan on using this on a centralized Git server where users can create arbitrary repositories under /gitroot, but I'd like to manage all the hooks that should be run centrally via a unified dispatch mechanism. Signed-off-by: Ævar Arnfjörð Bjarmason <> Signed-off-by: Junio C Hamano <>
Diffstat (limited to 'run-command.c')
1 files changed, 4 insertions, 1 deletions
diff --git a/run-command.c b/run-command.c
index c726010..aa85cd5 100644
--- a/run-command.c
+++ b/run-command.c
@@ -815,7 +815,10 @@ const char *find_hook(const char *name)
static struct strbuf path = STRBUF_INIT;
- strbuf_git_path(&path, "hooks/%s", name);
+ if (git_hooks_path)
+ strbuf_addf(&path, "%s/%s", git_hooks_path, name);
+ else
+ strbuf_git_path(&path, "hooks/%s", name);
if (access(path.buf, X_OK) < 0)
return NULL;
return path.buf;