diff options
author | Benjamin C Meyer <ben@meyerhome.net> | 2013-11-06 20:40:06 -0500 |
---|---|---|
committer | Benjamin C Meyer <ben@meyerhome.net> | 2013-11-06 21:51:19 -0500 |
commit | a7b60551d2fb4ce663f0b4fbc9b762c78c03cc8a (patch) | |
tree | 5a901f9db63b4806544f1cb59366c6fc3c87dda9 | |
parent | ea45bdbaba77707f7447626db43fb36a75648650 (diff) | |
download | git-hooks-a7b60551d2fb4ce663f0b4fbc9b762c78c03cc8a.tar.gz git-hooks-a7b60551d2fb4ce663f0b4fbc9b762c78c03cc8a.tar.bz2 |
Behave much better when not in a git repository
or when the repository is a bare repository
Signed-off-by: Benjamin C Meyer <ben@meyerhome.net>
-rwxr-xr-x | git-hooks | 12 |
1 files changed, 8 insertions, 4 deletions
@@ -34,10 +34,14 @@ function hook_dirs hook="" fi echo "${HOME}/.git_hooks${hook}" - GITDIR=`git rev-parse --git-dir` - cd $GITDIR/.. - echo "${PWD}/git_hooks${hook}" - echo "${PWD}/.githooks${hook}" + git rev-parse --git-dir &> /dev/null + if [ $? -eq 0 ]; then + if [ $(git rev-parse --is-bare-repository) = 'false' ]; then + cd $(git rev-parse --show-toplevel) + echo "${PWD}/git_hooks${hook}" + echo "${PWD}/.githooks${hook}" + fi + fi eval echo "`git config hooks.global`"${hook} } |