From: Thierry Volpiatto <thierry.volpiatto@gmail.com>
To: emacs-devel@gnu.org
Subject: Re: dired-do-copy may create infinite directory hierarchy, again
Date: Thu, 29 Mar 2012 08:41:19 +0200 [thread overview]
Message-ID: <87bonf7vu8.fsf@gmail.com> (raw)
In-Reply-To: 87fwcsw1td.fsf@web.de
Hi Michael,
Michael Heerdegen <michael_heerdegen@web.de> writes:
> Hi,
>
> I had sent a reply to
>
> bug#10489: 24.0.92; dired-do-copy may create infinite directory hierarchy
>
> after it had been closed, saying that there are still problems.
> Unfortunately I got no answer. Since it was an important bug: Can
> please somebody have a look? Thanks.
Thanks for this, you should open a new bug.
> This was my message:
>
>
>
> Hello again,
>
> I'm afraid there are still problems. I encountered these two:
>
>
> 1. Creating symlinks to parent directories doesn't work anymore.
>
> E.g. if you have a directory "~/test/dir1/", open a dired for "~", go to
> "test/", hit S, enter "~/test/dir1/" and hit RET. You get the error
>
> dired-create-files: Cannot copy `/home/micha/test' into its
> subdirectory `/home/micha/test/dir1/test'
>
> But I only wanted a symlink... This worked in Emacs 23.
>
Need to be fixed.
> 2. Symlinks to parent directories (still) lead to ininite loops when
> copying containing dir.
>
> To use the above example: just create this symlink from outside Emacs,
> so you get e.g. this:
>
> /home/micha/test/dir1:
> total used in directory 8,0K available 94267456
> drwxr-xr-x 2 micha users 4,0K Mär 22 02:32 .
> drwxr-xr-x 3 micha users 4,0K Mär 22 02:33 ..
> lrwxrwxrwx 1 micha users 22 Mär 22 02:32 test -> /home/micha/test
>
>
> Now dired "~", and copy "~/test" to "~/test2". You get a hierarchy
>
> ~/test2/dir1/test/dir1/test/...
>
> again (the command terminates without error, btw). And all these
> are real directories, and _not_ symlinks!
This is because the loop of copy-directory test the file it copy with
`file-directory-p' instead of testing if the car of its
`file-attributes' is non-nil.
--8<---------------cut here---------------start------------->8---
diff --git a/lisp/files.el b/lisp/files.el
--- a/lisp/files.el
+++ b/lisp/files.el
@@ -5102,10 +5102,10 @@
;; We do not want to copy "." and "..".
(directory-files directory 'full
directory-files-no-dot-files-regexp))
- (if (file-directory-p file)
- (copy-directory file newname keep-time parents)
- (let ((target (expand-file-name (file-name-nondirectory file) newname))
- (attrs (file-attributes file)))
+ (let ((target (expand-file-name (file-name-nondirectory file) newname))
+ (attrs (file-attributes file)))
+ (if (eq t (car attrs)) ; A directory but not a symlink.
+ (copy-directory file newname keep-time parents)
(if (stringp (car attrs)) ; Symbolic link
(make-symbolic-link (car attrs) target t)
(copy-file file target t keep-time)))))
--8<---------------cut here---------------end--------------->8---
This patch should fix it, but not fully tested, please have a look.
>
> I also wonder why dired doesn't copy the symlink itself, but copies the
> target instead? This seems to be the case also in other examples. If I
> copy a directory containing any symlinks with dired, copying always
> copies the targets of the symlinks.
The patch above should fix this.
>
> Michael
>
>
--
Thierry
Get my Gnupg key:
gpg --keyserver pgp.mit.edu --recv-keys 59F29997
next prev parent reply other threads:[~2012-03-29 6:41 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2012-03-29 2:58 dired-do-copy may create infinite directory hierarchy, again Michael Heerdegen
2012-03-29 6:41 ` Thierry Volpiatto [this message]
2012-03-29 17:45 ` Thierry Volpiatto
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=87bonf7vu8.fsf@gmail.com \
--to=thierry.volpiatto@gmail.com \
--cc=emacs-devel@gnu.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
Code repositories for project(s) associated with this external index
https://git.savannah.gnu.org/cgit/emacs.git
https://git.savannah.gnu.org/cgit/emacs/org-mode.git
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.