diff --git a/scripts/install-git-hooks b/scripts/install-git-hooks index ed1641a..349a944 100755 --- a/scripts/install-git-hooks +++ b/scripts/install-git-hooks @@ -24,6 +24,7 @@ cdup=$(git rev-parse --show-cdup) || exit cd "${cdup:-./}" || exit GIT_DIR=$(git rev-parse --git-dir) || exit +SCRIPTS_DIR=$(dirname "$(readlink -f "${BASH_SOURCE[0]}")") check_snippet() { @@ -119,22 +120,10 @@ check_scripts() is_eq "$GIT_DIR"/hooks/kernel-source-pre-commit scripts/git-pre-commit } -# try to create a relative symlink if possible -relative_scripts_dir() -{ - local toplevel=$PWD - if test "$toplevel/.git" -ef "$GIT_DIR"; then - echo "../../scripts" - else - echo "$toplevel/scripts" - fi -} - install_scripts() { chmod +x "$GIT_DIR"/hooks/pre-commit - dir=$(relative_scripts_dir) - ln -sf "$dir"/git-pre-commit "$GIT_DIR"/hooks/kernel-source-pre-commit + ln -rfs "$SCRIPTS_DIR"/git-pre-commit "$GIT_DIR"/hooks/kernel-source-pre-commit if test -r "$GIT_DIR"/hooks/pre-merge-commit ; then echo "Cannot install pre-merge-commit hook, upstream your hook to kernel-source/scripts" else