branch: elpa/magit
commit a81bac4770b1d482627342416356cbe2abc5c28a
Author: Jonas Bernoulli <[email protected]>
Commit: Jonas Bernoulli <[email protected]>
magit-process-git-arguments: Only set core.hooksPath for async processes
---
lisp/magit-git.el | 16 ++++++++++++----
lisp/magit-process.el | 18 +++++++++---------
2 files changed, 21 insertions(+), 13 deletions(-)
diff --git a/lisp/magit-git.el b/lisp/magit-git.el
index d9e1293c43..21fad00d9d 100644
--- a/lisp/magit-git.el
+++ b/lisp/magit-git.el
@@ -402,9 +402,16 @@ is remote."
magit-remote-git-executable
magit-git-executable))
-(defun magit-process-git-arguments--length ()
- (+ (length magit-git-global-arguments)
- (if magit--overriding-githook-directory 2 0)))
+(defun magit-process-git-arguments--split (program args)
+ (if (equal program (magit-git-executable))
+ (let* ((length (length magit-git-global-arguments))
+ (global (seq-take args length))
+ (local (seq-drop args length)))
+ (when (equal (car local) "-c")
+ (setq global (append global (seq-take local 2)))
+ (setq local (seq-drop local 2)))
+ (list global local))
+ (list nil args)))
(defun magit-process-git-arguments (args &optional async)
"Prepare ARGS for a function that invokes Git.
@@ -433,7 +440,8 @@ to do the following.
magit-overriding-githook-directory))))
(setq args
(append magit-git-global-arguments
- (and magit--overriding-githook-directory
+ (and async
+ magit--overriding-githook-directory
(list "-c" (format "core.hooksPath=%s"
magit--overriding-githook-directory)))
(flatten-tree args)))
diff --git a/lisp/magit-process.el b/lisp/magit-process.el
index 6ec2b5650f..a5cf303c4f 100644
--- a/lisp/magit-process.el
+++ b/lisp/magit-process.el
@@ -809,16 +809,17 @@ Magit status buffer."
(defun magit-process--format-arguments (program args)
(cond
((and args (equal program (magit-git-executable)))
- (let ((global (magit-process-git-arguments--length)))
+ (pcase-let ((`(,global ,local)
+ (magit-process-git-arguments--split program args)))
(concat
(propertize (file-name-nondirectory program)
'font-lock-face 'magit-section-heading)
" "
(propertize (magit--ellipsis)
'font-lock-face 'magit-section-heading
- 'help-echo (string-join (seq-take args global) " "))
+ 'help-echo (string-join global " "))
" "
- (propertize (mapconcat #'shell-quote-argument (seq-drop args global) "
")
+ (propertize (mapconcat #'shell-quote-argument local " ")
'font-lock-face 'magit-section-heading))))
((and args (equal program shell-file-name))
(propertize (cadr args)
@@ -880,11 +881,10 @@ Magit status buffer."
((section
(magit-get-section
`((commit . ,(magit-rev-parse "HEAD"))
- (,(pcase (car (seq-drop
- (process-command process)
- (1+ (magit-process-git-arguments--length))))
- ((or "rebase" "am") 'rebase-sequence)
- ((or "cherry-pick" "revert") 'sequence)))
+ (,(pcase-let ((`(,cmd . ,args) (process-command process)))
+ (pcase (cadr (magit-process-git-arguments--split cmd
args))
+ ((or "rebase" "am") 'rebase-sequence)
+ ((or "cherry-pick" "revert") 'sequence))))
(status)))))
(goto-char (oref section start))
(magit-section-update-highlight))))))
@@ -1119,7 +1119,7 @@ as argument."
(defun magit-process-set-mode-line (program args)
"Display the git command (sans arguments) in the mode line."
(when (equal program (magit-git-executable))
- (setq args (nthcdr (magit-process-git-arguments--length) args)))
+ (setq args (cadr (magit-process-git-arguments--split program args))))
(let ((str (concat " " (propertize
(concat (file-name-nondirectory program)
(and args (concat " " (car args))))