install: allow installing in a worktree

Signed-off-by: Alexandre Belloni <alexandre.belloni@bootlin.com>
diff --git a/README.md b/README.md
index 5e983ec..22ef34d 100644
--- a/README.md
+++ b/README.md
@@ -66,6 +66,6 @@
 ## Uninstallation
 
 1. Go to the "soc" Linux kernel repository.
-2. rm -f .git/hooks/post-commit .git/hooks/post-applypatch .git/hooks/post-merge
+2. HOOKS="$(git rev-parse --git-dir)/hooks"; rm -f $HOOKS/post-commit $HOOKS/post-applypatch $HOOKS/post-merge
 
 next-analysis from: https://github.com/krzk/next-analysis
diff --git a/install.sh b/install.sh
index 36757ab..b3f9df1 100755
--- a/install.sh
+++ b/install.sh
@@ -12,9 +12,11 @@
 
 SELF_DIR="$(dirname "${BASH_SOURCE[0]}")"
 
-test -f .git/hooks/post-commit && die "Hooks exist, run rm -f .git/hooks/post-commit .git/hooks/post-applypatch .git/hooks/post-merge"
-test -f .git/hooks/post-applypatch && die "Hooks exist, run rm -f .git/hooks/post-commit .git/hooks/post-applypatch .git/hooks/post-merge"
-test -f .git/hooks/post-merge && die "Hooks exist, run rm -f .git/hooks/post-commit .git/hooks/post-applypatch .git/hooks/post-merge"
+HOOKS="$(git rev-parse --git-dir)/hooks"
+
+test -f "$HOOKS/post-commit" && die "Hooks exist, run rm -f $HOOKS/post-commit $HOOKS/post-applypatch $HOOKS/post-merge"
+test -f "$HOOKS/post-applypatch" && die "Hooks exist, run rm -f $HOOKS/post-commit $HOOKS/post-applypatch $HOOKS/post-merge"
+test -f "$HOOKS/post-merge" && die "Hooks exist, run rm -f $HOOKS/post-commit $HOOKS/post-applypatch $HOOKS/post-merge"
 
 # Sanity check:
 LINUS_URL="$(git remote get-url linus)"
@@ -24,10 +26,12 @@
 	die "'linus' remote points somewhere else or not running in soc Linux kernel repo?"
 fi
 
-sed -e "s+__REPLACE__TOOLS__+${SELF_DIR}/+" "${SELF_DIR}/git-hooks-post-commit" > .git/hooks/post-commit
-sed -e "s+__REPLACE__TOOLS__+${SELF_DIR}/+" "${SELF_DIR}/git-hooks-post-commit" > .git/hooks/post-applypatch
-sed -e "s+__REPLACE__TOOLS__+${SELF_DIR}/+" "${SELF_DIR}/git-hooks-post-merge" > .git/hooks/post-merge
+mkdir -p "$HOOKS"
 
-chmod a+x .git/hooks/post-commit .git/hooks/post-applypatch .git/hooks/post-merge
+sed -e "s+__REPLACE__TOOLS__+${SELF_DIR}/+" "${SELF_DIR}/git-hooks-post-commit" > "$HOOKS/post-commit"
+sed -e "s+__REPLACE__TOOLS__+${SELF_DIR}/+" "${SELF_DIR}/git-hooks-post-commit" > "$HOOKS/post-applypatch"
+sed -e "s+__REPLACE__TOOLS__+${SELF_DIR}/+" "${SELF_DIR}/git-hooks-post-merge" > "$HOOKS/post-merge"
+
+chmod a+x "$HOOKS/post-commit" "$HOOKS/post-applypatch" "$HOOKS/post-merge"
 
 echo "Hooks installed from ${SELF_DIR}"