---
> Somthing's a little confused here.  My best guess at this point
> is that the patch you posted may not have been what you intended,
> since it only changes the behavior of Emacs 22 and earlier

My intention was to restore magit's behaviour before my patch that
added server-running-p in the first place with the least effort
possible. However, you're right that compatibility should be preserved
if at all possible.

So here's a patch that simply forward-ports server-running-p from
Emacs 23 as magit-server-running-p for Emacs < 22 and calls
server-running-p on >= 23.

 magit.el |   29 ++++++++++++++++++++++++++++-
 1 files changed, 28 insertions(+), 1 deletions(-)

diff --git a/magit.el b/magit.el
index 1a1283e..1436cfe 100644
--- a/magit.el
+++ b/magit.el
@@ -3722,11 +3722,38 @@ With a non numeric prefix ARG, show all entries"
 
 (eval-when-compile (require 'server))
 
+(defun magit-server-running-p ()
+  "Test whether server is running (works with < 23 as well).
+
+Return values:
+  nil              the server is definitely not running.
+  t                the server seems to be running.
+  something else   we cannot determine whether it's running without using
+                   commands which may have to wait for a long time."
+  (if (functionp 'server-running-p)
+      (server-running-p)
+    (condition-case nil
+       (if server-use-tcp
+           (with-temp-buffer
+             (insert-file-contents-literally (expand-file-name server-name 
server-auth-dir))
+             (or (and (looking-at "127\\.0\\.0\\.1:[0-9]+ \\([0-9]+\\)")
+                      (assq 'comm
+                            (process-attributes
+                             (string-to-number (match-string 1))))
+                      t)
+                 :other))
+         (delete-process
+          (make-network-process
+           :name "server-client-test" :family 'local :server nil :noquery t
+           :service (expand-file-name server-name server-socket-dir)))
+         t)
+      (file-error nil))))
+
 (defun magit-interactive-rebase ()
   "Start a git rebase -i session, old school-style."
   (interactive)
   (require 'server)
-  (unless (server-running-p)
+  (unless (magit-server-running-p)
     (server-start))
   (let* ((section (get-text-property (point) 'magit-section))
         (commit (and (member 'commit (magit-section-context-type section))
-- 
1.6.3.3

Reply via email to