diff options
Diffstat (limited to 'etc')
-rw-r--r-- | etc/completions/_git-hook | 2 | ||||
-rw-r--r-- | etc/functions/git-hook | 7 |
2 files changed, 6 insertions, 3 deletions
diff --git a/etc/completions/_git-hook b/etc/completions/_git-hook index 92b4d17..20308c6 100644 --- a/etc/completions/_git-hook +++ b/etc/completions/_git-hook @@ -10,6 +10,8 @@ if [[ -n $GIT_DIR && -d $GIT_DIR ]] { hook_dir=$PWD/hooks } elif [[ $PWD == */hooks ]] { hook_dir=$PWD +} else { + hook_dir=$(git rev-parse --git-dir)/hooks } if (( CURRENT == 2 )) { diff --git a/etc/functions/git-hook b/etc/functions/git-hook index bb44e05..5243ee1 100644 --- a/etc/functions/git-hook +++ b/etc/functions/git-hook @@ -14,7 +14,8 @@ if [[ -n $GIT_DIR && -d $GIT_DIR ]] { } elif [[ $PWD == */hooks ]] { hook_dir=$PWD } else { - fdie 'No git or hook directory found.'; return + hook_dir=$(git rev-parse --git-dir)/hooks || + return } function usage { @@ -26,7 +27,7 @@ function usage { function hook_enable { if [[ -e $hook_dir/$hook ]] { if ! [[ -x $hook_dir/$hook ]] { - chmod u+x $hook_dir/$hook + chmod +x $hook_dir/$hook } } else { fdie "No such hook: '$hook'"; return @@ -36,7 +37,7 @@ function hook_enable { function hook_disable { if [[ -e $hook_dir/$hook ]] { if [[ -x $hook_dir/$hook ]] { - chmod u-x $hook_dir/$hook + chmod -x $hook_dir/$hook } } else { fdie "No such hook: '$hook'"; return |