diff options
author | Daniel Friesel <derf@derf.homelinux.org> | 2008-10-24 23:42:00 +0200 |
---|---|---|
committer | Daniel Friesel <derf@derf.homelinux.org> | 2008-10-24 23:42:00 +0200 |
commit | 0fa756c25e2e45c04db7e0c2c22a7c8d08cec0c1 (patch) | |
tree | b0e5278834f1181537509a39fa05c78dfa623d6e /etc | |
parent | 9fda02e0e9e2187c101f2d8c1120336abc43f7d5 (diff) |
git-hook: Use git rev-parse (pointed out by mxey)
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 |