Subject: Re: bug#32304: 27.0.50; tramp-tests issue with double slash

From: Michael Albinus <[email-masked]>
Date: Mon, 30 Jul 2018 12:43:46 +0200

Ken Brown <[email-masked]> writes:

> Hi Michael,

Hi Ken,

> I think something further must be needed.  The test still fails in the
> same way.

There's another patch, could you pls check?

> Best regards,
> Ken

Best regards, Michael.

diff --git a/lisp/net/tramp.el b/lisp/net/tramp.el
index d56b09a604..1af2defd58 100644
--- a/lisp/net/tramp.el
+++ b/lisp/net/tramp.el
@@ -3567,16 +3567,20 @@ tramp-handle-substitute-in-file-name
     ;; First, we must replace environment variables.
     (setq filename (tramp-replace-environment-variables filename))
     (with-parsed-tramp-file-name filename nil
-      ;; We do not want to replace environment variables, again.
+      ;; We do not want to replace environment variables, again.  "//"
+      ;; has a special meaning at the beginning of a file name on
+      ;; Cygwin and MS-Windows, we must remove it.
       (let (process-environment)
 	;; Ignore in LOCALNAME everything before "//" or "/~".
 	(when (stringp localname)
 	  (if (string-match "//\\(/\\|~\\)" localname)
-	      (setq filename (substitute-in-file-name localname))
+	      (setq filename
+                    (replace-regexp-in-string
+                     "\\`/+" "/" (substitute-in-file-name localname)))
 	    (setq filename
 		  (concat (file-remote-p filename)
-			  (tramp-run-real-handler
-			   'substitute-in-file-name (list localname)))))))
+			  (replace-regexp-in-string
+                           "\\`/+" "/" (substitute-in-file-name localname)))))))
       ;; "/m:h:~" does not work for completion.  We use "/m:h:~/".
       (if (and (stringp localname) (string-equal "~" localname))
 	  (concat filename "/")