Subject: Re: bug#15737: 24.3; copy-directory ignores copy-contents when using tramp

From: Michael Albinus <[email-masked]>
Date: Mon, 28 Oct 2013 09:23:15 +0100

Kyle Mahan <[email-masked]> writes:

> Hello,

Hi,

> Trying to copy the contents of a local directory to a remote one
> (trying to get behavior like "scp -r src/* user@host:dest/") , I
> noticed that the "copy-contents" flag is (silently?) ignored when the
> destination is remote. So the directory, rather than its contents is
> copied to the destination.

Thanks for the report, I could reproduce it here. Could you, please,
check the following patch:

--8<---------------cut here---------------start------------->8---
*** /usr/local/src/emacs-24/lisp/net/tramp-sh.el.~111399~	2013-10-28 09:18:09.197122236 +0100
--- /usr/local/src/emacs-24/lisp/net/tramp-sh.el	2013-10-28 09:17:24.648901345 +0100
***************
*** 1912,1918 ****
    (let ((t1 (tramp-tramp-file-p dirname))
  	(t2 (tramp-tramp-file-p newname)))
      (with-parsed-tramp-file-name (if t1 dirname newname) nil
!       (if (and (tramp-get-method-parameter method 'tramp-copy-recursive)
  	       ;; When DIRNAME and NEWNAME are remote, they must have
  	       ;; the same method.
  	       (or (null t1) (null t2)
--- 1912,1919 ----
    (let ((t1 (tramp-tramp-file-p dirname))
  	(t2 (tramp-tramp-file-p newname)))
      (with-parsed-tramp-file-name (if t1 dirname newname) nil
!       (if (and (not copy-contents)
! 	       (tramp-get-method-parameter method 'tramp-copy-recursive)
  	       ;; When DIRNAME and NEWNAME are remote, they must have
  	       ;; the same method.
  	       (or (null t1) (null t2)
***************
*** 1935,1941 ****
  	     'copy dirname newname keep-date))
  	;; We must do it file-wise.
  	(tramp-run-real-handler
! 	 'copy-directory (list dirname newname keep-date parents)))
  
        ;; When newname did exist, we have wrong cached values.
        (when t2
--- 1936,1945 ----
  	     'copy dirname newname keep-date))
  	;; We must do it file-wise.
  	(tramp-run-real-handler
! 	 'copy-directory
! 	 (if copy-contents
! 	     (list dirname newname keep-date parents copy-contents)
! 	   (list dirname newname keep-date parents))))
  
        ;; When newname did exist, we have wrong cached values.
        (when t2
--8<---------------cut here---------------end--------------->8---

> Thanks :)

Best regards, Michael.