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

    magit-run-git-hook: Advise message while running hook
---
 lisp/magit-git.el | 9 ++++-----
 1 file changed, 4 insertions(+), 5 deletions(-)

diff --git a/lisp/magit-git.el b/lisp/magit-git.el
index adf17ad0a3..c28dc6b353 100644
--- a/lisp/magit-git.el
+++ b/lisp/magit-git.el
@@ -3085,12 +3085,11 @@ out.  Only existing branches can be selected."
       (when (and (boundp hook)
                  (symbol-value hook))
         (magit--client-message "Running %s..." hook)
-        (apply #'run-hook-with-args hook args)
+        (advice-add 'message :override #'magit--client-message)
+        (unwind-protect (apply #'run-hook-with-args hook args)
+          (advice-remove 'message #'magit--client-message))
         (magit--client-message "Running %s...done" hook))))
-  ;; Emacsclient prints the returned value to stdout.  We cannot prevent
-  ;; that, but we can use something that looks like we actually *wanted*
-  ;; to print (which we don't).
-  '---)
+  '---) ; Emacsclient insists on printing the value.
 
 (defun magit--client-message (format-string &rest args)
   ;; See `server-process-filter'.

Reply via email to