branch: elpa/magit
commit 4469b3b13dbe244e2bc2d999e9ce7e7e03912d6e
Author: Jonas Bernoulli <[email protected]>
Commit: Jonas Bernoulli <[email protected]>

    magit-process-git-arguments: Only set core.hooksPath for local processes
    
    Likewise in `magit-process-environment' to not set
    SHADOWED_GITHOOK_DIRECTORY on remote systems where
    that directory would not exist.
---
 lisp/magit-git.el     | 42 ++++++++++++++++++++++--------------------
 lisp/magit-process.el |  1 +
 2 files changed, 23 insertions(+), 20 deletions(-)

diff --git a/lisp/magit-git.el b/lisp/magit-git.el
index 21fad00d9d..40ba7f295d 100644
--- a/lisp/magit-git.el
+++ b/lisp/magit-git.el
@@ -425,26 +425,28 @@ to do the following.
   and valid, set `core.hooksPath' by adding additional arguments to ARGS.
 * Flatten ARGS, removing nil arguments.
 * If `system-type' is `windows-nt', encode ARGS to `w32-ansi-code-page'."
-  (cond ((not async))
-        (magit--overriding-githook-directory)
-        ((eq magit-overriding-githook-directory 'magit)
-         (setq magit--overriding-githook-directory
-               (magit-convert-filename-for-git
-                (expand-file-name "git-hooks"
-                                  (locate-dominating-file
-                                   (locate-library "magit.el") "git-hooks")))))
-        ((and magit-overriding-githook-directory
-              (file-directory-p magit-overriding-githook-directory))
-         (setq magit--overriding-githook-directory
-               (magit-convert-filename-for-git
-                magit-overriding-githook-directory))))
-  (setq args
-        (append magit-git-global-arguments
-                (and async
-                     magit--overriding-githook-directory
-                     (list "-c" (format "core.hooksPath=%s"
-                                        magit--overriding-githook-directory)))
-                (flatten-tree args)))
+  (let ((githookp (and async (not (file-remote-p default-directory)))))
+    (cond
+      ((not githookp))
+      (magit--overriding-githook-directory)
+      ((eq magit-overriding-githook-directory 'magit)
+       (setq magit--overriding-githook-directory
+             (magit-convert-filename-for-git
+              (expand-file-name "git-hooks"
+                                (locate-dominating-file
+                                 (locate-library "magit.el") "git-hooks")))))
+      ((and magit-overriding-githook-directory
+            (file-directory-p magit-overriding-githook-directory))
+       (setq magit--overriding-githook-directory
+             (magit-convert-filename-for-git
+              magit-overriding-githook-directory))))
+    (setq args
+          (append magit-git-global-arguments
+                  (and githookp
+                       magit--overriding-githook-directory
+                       (list "-c" (format "core.hooksPath=%s"
+                                          
magit--overriding-githook-directory)))
+                  (flatten-tree args))))
   (if (and (eq system-type 'windows-nt) (boundp 'w32-ansi-code-page))
       ;; On w32, the process arguments *must* be encoded in the
       ;; current code-page (see #3250).
diff --git a/lisp/magit-process.el b/lisp/magit-process.el
index a5cf303c4f..6b62293e72 100644
--- a/lisp/magit-process.el
+++ b/lisp/magit-process.el
@@ -542,6 +542,7 @@ eol conversion."
        ,@process-environment))
     (`(,@magit-git-environment
        ,@(and magit--overriding-githook-directory
+              (not (file-remote-p default-directory))
               (list (concat "SHADOWED_GITHOOK_DIRECTORY="
                             (magit--shadowed-githook-directory))))
        ;; The various w32 hacks are only applicable when running on the

Reply via email to