Subject: bug#10489: 24.0.92; dired-do-copy may create infinite directory hierarchy

From: Thierry Volpiatto <[email-masked]>
Date: Fri, 13 Jan 2012 14:55:42 +0100

Hi Michael,

Michael Albinus <[email-masked]> writes:

> Thierry Volpiatto <[email-masked]> writes:
>
>> Hi Michael,
>
> Hi Thierry,
>
>> I want to only suppress the use of:
>> (copy-directory "/sudo:host:/home/user/Test" "/home/user/Test")
>
> Do you know `tramp-default-proxies-alist'? With that toy, "/sudo:host:"
> can be another machine but your local one. You really don't know,
> without going into deep Tramp interna.
No I didn't know, I did differently, see below.

>> (copy-directory "/sudo:host:/home/user/Test" "/sudo:host:/home/user/Test")
>
> That would be reasonable to suppress.
We must suppress this as it cause infinite creation of subdir in ~/Test.

> But you don't need a special remote test for this. Just compare the
> results of `file-truename', as suggested by Eli. This shall work also
> for remote files automagically.
Ok good, but I did differently in last patch:

--8<---------------cut here---------------start------------->8---
(when (equal (or (and (equal "sudo" (file-remote-p (file-name-as-directory from) 'method))
                      (file-remote-p (file-name-as-directory from) 'localname))
                 (file-name-as-directory from))
             (or (and (equal "sudo" (file-remote-p (file-name-as-directory to) 'method))
                      (file-remote-p (file-name-as-directory to) 'localname))
                 (file-name-as-directory to)))
  (error "Can't copy directory `%s' on itself" from))
--8<---------------cut here---------------end--------------->8---

Which fail for the example below.
> If somebody wants to apply
>
> (copy-directory "/ssh:host:/home/user/Test" "/scp:host:/home/user/Test")
>
> you can't suppress. Same for using different hostnames which are aliases
> for the same machine, etc pp.
Yes right.
BTW, working on this, I found another bug for

(copy-directory "/ssh:host:/home/user/Test" "/home/user/Test")

This seem to overwrite "/home/user/Test".
Doing the same operation from Dired create "/home/user/Test/Test".

But I think it's easy to fix, just need to move the tramp block lower in
copy-directory, have a look.

So I will finish writing this patch with the compare file function
suggested by Juanma.

-- 
  Thierry
Get my Gnupg key:
gpg --keyserver pgp.mit.edu --recv-keys 59F29997