From 0fa756c25e2e45c04db7e0c2c22a7c8d08cec0c1 Mon Sep 17 00:00:00 2001 From: Daniel Friesel Date: Fri, 24 Oct 2008 23:42:00 +0200 Subject: git-hook: Use git rev-parse (pointed out by mxey) --- etc/completions/_git-hook | 2 ++ etc/functions/git-hook | 7 ++++--- 2 files changed, 6 insertions(+), 3 deletions(-) (limited to 'etc') 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 -- cgit v1.2.3