From d7f2a65cc22f1383b7d9a0e78e7bb90c19f56a39 Mon Sep 17 00:00:00 2001
From: Michael Albinus <michael.albinus@gmx.de>
Date: Mon, 19 Nov 2012 16:25:10 +0100
Subject: [PATCH] * net/tramp-sh.el (tramp-do-copy-or-rename-file): If both
 files are remote, check out-of-band property for both.

---
 lisp/ChangeLog       |  5 +++++
 lisp/net/tramp-sh.el | 16 +++++++++-------
 2 files changed, 14 insertions(+), 7 deletions(-)

diff --git a/lisp/ChangeLog b/lisp/ChangeLog
index 85e762497e4..8447be48e14 100644
--- a/lisp/ChangeLog
+++ b/lisp/ChangeLog
@@ -1,3 +1,8 @@
+2012-11-19  Michael Albinus  <michael.albinus@gmx.de>
+
+	* net/tramp-sh.el (tramp-do-copy-or-rename-file): If both files
+	are remote, check out-of-band property for both.
+
 2012-11-19  Stefan Monnier  <monnier@iro.umontreal.ca>
 
 	* window.el (switch-to-buffer): Re-add the warning that was lost in the
diff --git a/lisp/net/tramp-sh.el b/lisp/net/tramp-sh.el
index 059e1e63c77..07da0b3dc16 100644
--- a/lisp/net/tramp-sh.el
+++ b/lisp/net/tramp-sh.el
@@ -1270,9 +1270,10 @@ target of the symlink differ."
          res-uid
          ;; 3. File gid.
          res-gid
-         ;; 4. Last access time, as a list of integers.  Normally this would be
-         ;; in the same format as `current-time', but the subseconds part is not
-         ;; currently implemented, and (0 0) denotes an unknown time.
+         ;; 4. Last access time, as a list of integers.  Normally this
+         ;; would be in the same format as `current-time', but the
+         ;; subseconds part is not currently implemented, and (0 0)
+         ;; denotes an unknown time.
          ;; 5. Last modification time, likewise.
          ;; 6. Last status change time, likewise.
          '(0 0) '(0 0) '(0 0)		;CCC how to find out?
@@ -1980,6 +1981,7 @@ file names."
     (error "Unknown operation `%s', must be `copy' or `rename'" op))
   (let ((t1 (tramp-tramp-file-p filename))
 	(t2 (tramp-tramp-file-p newname))
+	(length (nth 7 (file-attributes (file-truename filename))))
 	(context (and preserve-selinux-context
 		      (apply 'file-selinux-context (list filename))))
 	pr tm)
@@ -2009,8 +2011,9 @@ file names."
 		 ok-if-already-exists keep-date preserve-uid-gid))
 
 	       ;; Try out-of-band operation.
-	       ((tramp-method-out-of-band-p
-		 v1 (nth 7 (file-attributes (file-truename filename))))
+	       ((and
+		 (tramp-method-out-of-band-p v1 length)
+		 (tramp-method-out-of-band-p v2 length))
 		(tramp-do-copy-or-rename-file-out-of-band
 		 op filename newname keep-date))
 
@@ -2038,8 +2041,7 @@ file names."
 
 	   ;; If the Tramp file has an out-of-band method, the
 	   ;; corresponding copy-program can be invoked.
-	   ((tramp-method-out-of-band-p
-	     v (nth 7 (file-attributes (file-truename filename))))
+	   ((tramp-method-out-of-band-p v length)
 	    (tramp-do-copy-or-rename-file-out-of-band
 	     op filename newname keep-date))
 
-- 
2.39.5