summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMichael Albinus <michael.albinus@gmx.de>2022-05-08 11:43:19 +0200
committerMichael Albinus <michael.albinus@gmx.de>2022-05-08 11:43:19 +0200
commite683b08b3fbbc1692e0053699c5cf2b7cbc803f6 (patch)
treee1bb81ae3a0f23a4fd53c5c8550df76b3359ecf5
parentafdf72eeb2afb5cf96a2f0168c94b97448026666 (diff)
downloademacs-e683b08b3fbbc1692e0053699c5cf2b7cbc803f6.tar.gz
Handle changed scp protocol in Tramp, don't merge
* lisp/net/tramp-sh.el (tramp-scp-force-scp-protocol): New defvar. (tramp-scp-force-scp-protocol): New defun. (tramp-do-copy-or-rename-file-out-of-band): Use it. (tramp-methods) <scp, scpx>: Use "%y". * lisp/net/tramp.el (tramp-methods): Adapt docstring.
-rw-r--r--lisp/net/tramp-sh.el43
-rw-r--r--lisp/net/tramp.el2
2 files changed, 42 insertions, 3 deletions
diff --git a/lisp/net/tramp-sh.el b/lisp/net/tramp-sh.el
index 67f5519bbfe..c4fbe4673b9 100644
--- a/lisp/net/tramp-sh.el
+++ b/lisp/net/tramp-sh.el
@@ -134,6 +134,15 @@ be auto-detected by Tramp.
The string is used in `tramp-methods'.")
+(defvar tramp-scp-force-scp-protocol nil
+ "Force scp protocol.
+
+It is the string \"-O\" if supported by the local scp (since
+release 8.6), otherwise the string \"\". If it is nil, it will
+be auto-detected by Tramp.
+
+The string is used in `tramp-methods'.")
+
;; Initialize `tramp-methods' with the supported methods.
;;;###tramp-autoload
(tramp--with-startup
@@ -170,7 +179,7 @@ The string is used in `tramp-methods'.")
(tramp-remote-shell-args ("-c"))
(tramp-copy-program "scp")
(tramp-copy-args (("-P" "%p") ("-p" "%k")
- ("%x") ("-q") ("-r") ("%c")))
+ ("%x") ("%y") ("-q") ("-r") ("%c")))
(tramp-copy-keep-date t)
(tramp-copy-recursive t)))
(add-to-list 'tramp-methods
@@ -186,7 +195,7 @@ The string is used in `tramp-methods'.")
(tramp-remote-shell-args ("-c"))
(tramp-copy-program "scp")
(tramp-copy-args (("-P" "%p") ("-p" "%k")
- ("%x") ("-q") ("-r") ("%c")))
+ ("%x") ("%y") ("-q") ("-r") ("%c")))
(tramp-copy-keep-date t)
(tramp-copy-recursive t)))
(add-to-list 'tramp-methods
@@ -2311,7 +2320,8 @@ The method used must be an out-of-band method."
?h (or host "") ?u (or user "") ?p (or port "")
?r listener ?c options ?k (if keep-date " " "")
?n (concat "2>" (tramp-get-remote-null-device v))
- ?x (tramp-scp-strict-file-name-checking v))
+ ?x (tramp-scp-strict-file-name-checking v)
+ ?y (tramp-scp-force-scp-protocol v))
copy-program (tramp-get-method-parameter v 'tramp-copy-program)
copy-keep-date (tramp-get-method-parameter
v 'tramp-copy-keep-date)
@@ -4818,6 +4828,33 @@ Goes through the list `tramp-inline-compress-commands'."
(setq tramp-scp-strict-file-name-checking "-T")))))))
tramp-scp-strict-file-name-checking)))
+(defun tramp-scp-force-scp-protocol (vec)
+ "Return the force scp protocol argument of the local scp."
+ (cond
+ ;; No options to be computed.
+ ((null (assoc "%y" (tramp-get-method-parameter vec 'tramp-copy-args)))
+ "")
+
+ ;; There is already a value to be used.
+ ((stringp tramp-scp-force-scp-protocol)
+ tramp-scp-force-scp-protocol)
+
+ ;; Determine the options.
+ (t (setq tramp-scp-force-scp-protocol "")
+ (let ((case-fold-search t))
+ (ignore-errors
+ (when (executable-find "scp")
+ (with-tramp-progress-reporter
+ vec 4 "Computing force scp protocol argument"
+ (with-temp-buffer
+ (tramp-call-process vec "scp" nil t nil "-O")
+ (goto-char (point-min))
+ (unless
+ (search-forward-regexp
+ "\\(illegal\\|unknown\\) option -- O" nil t)
+ (setq tramp-scp-force-scp-protocol "-O")))))))
+ tramp-scp-force-scp-protocol)))
+
(defun tramp-timeout-session (vec)
"Close the connection VEC after a session timeout.
If there is just some editing, retry it after 5 seconds."
diff --git a/lisp/net/tramp.el b/lisp/net/tramp.el
index 8baf72464dc..63ea8a283c6 100644
--- a/lisp/net/tramp.el
+++ b/lisp/net/tramp.el
@@ -255,6 +255,8 @@ pair of the form (KEY VALUE). The following KEYs are defined:
- \"%n\" expands to \"2>/dev/null\".
- \"%x\" is replaced by the `tramp-scp-strict-file-name-checking'
argument if it is supported.
+ - \"%y\" is replaced by the `tramp-scp-force-scp-protocol'
+ argument if it is supported.
The existence of `tramp-login-args', combined with the
absence of `tramp-copy-args', is an indication that the