summaryrefslogtreecommitdiff
path: root/etc
diff options
context:
space:
mode:
authorDaniel Friesel <derf@derf.homelinux.org>2008-10-24 23:42:00 +0200
committerDaniel Friesel <derf@derf.homelinux.org>2008-10-24 23:42:00 +0200
commit0fa756c25e2e45c04db7e0c2c22a7c8d08cec0c1 (patch)
treeb0e5278834f1181537509a39fa05c78dfa623d6e /etc
parent9fda02e0e9e2187c101f2d8c1120336abc43f7d5 (diff)
git-hook: Use git rev-parse (pointed out by mxey)
Diffstat (limited to 'etc')
-rw-r--r--etc/completions/_git-hook2
-rw-r--r--etc/functions/git-hook7
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