checkout: add --ignore-other-wortrees
[gitweb.git] / git-am.sh
index ee61a77d717a7210a1cf614914ab62788fd5e4fc..66803d12764d0df8970092ba057ded9442c86352 100755 (executable)
--- a/git-am.sh
+++ b/git-am.sh
@@ -810,10 +810,10 @@ To restore the original branch and stop patching run \"\$cmdline --abort\"."
                continue
        fi
 
-       if test -x "$GIT_DIR"/hooks/applypatch-msg
+       hook="$(git rev-parse --git-path hooks/applypatch-msg)"
+       if test -x "$hook"
        then
-               "$GIT_DIR"/hooks/applypatch-msg "$dotest/final-commit" ||
-               stop_here $this
+               "$hook" "$dotest/final-commit" || stop_here $this
        fi
 
        if test -f "$dotest/final-commit"
@@ -887,9 +887,10 @@ did you forget to use 'git add'?"
                stop_here_user_resolve $this
        fi
 
-       if test -x "$GIT_DIR"/hooks/pre-applypatch
+       hook="$(git rev-parse --git-path hooks/pre-applypatch)"
+       if test -x "$hook"
        then
-               "$GIT_DIR"/hooks/pre-applypatch || stop_here $this
+               "$hook" || stop_here $this
        fi
 
        tree=$(git write-tree) &&
@@ -916,18 +917,17 @@ did you forget to use 'git add'?"
                echo "$(cat "$dotest/original-commit") $commit" >> "$dotest/rewritten"
        fi
 
-       if test -x "$GIT_DIR"/hooks/post-applypatch
-       then
-               "$GIT_DIR"/hooks/post-applypatch
-       fi
+       hook="$(git rev-parse --git-path hooks/post-applypatch)"
+       test -x "$hook" && "$hook"
 
        go_next
 done
 
 if test -s "$dotest"/rewritten; then
     git notes copy --for-rewrite=rebase < "$dotest"/rewritten
-    if test -x "$GIT_DIR"/hooks/post-rewrite; then
-       "$GIT_DIR"/hooks/post-rewrite rebase < "$dotest"/rewritten
+    hook="$(git rev-parse --git-path hooks/post-rewrite)"
+    if test -x "$hook"; then
+       "$hook" rebase < "$dotest"/rewritten
     fi
 fi