From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: Thierry Volpiatto Newsgroups: gmane.emacs.bugs Subject: bug#11130: [PATCH] Reopen bug#10489: 24.0.92; dired-do-copy may create infinite directory hierarchy Date: Fri, 30 Mar 2012 07:18:10 +0200 Message-ID: <87mx6yu0od.fsf@gmail.com> NNTP-Posting-Host: plane.gmane.org Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="=-=-=" X-Trace: dough.gmane.org 1333084786 16887 80.91.229.3 (30 Mar 2012 05:19:46 GMT) X-Complaints-To: usenet@dough.gmane.org NNTP-Posting-Date: Fri, 30 Mar 2012 05:19:46 +0000 (UTC) To: 11130@debbugs.gnu.org Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Fri Mar 30 07:19:45 2012 Return-path: Envelope-to: geb-bug-gnu-emacs@m.gmane.org Original-Received: from lists.gnu.org ([208.118.235.17]) by plane.gmane.org with esmtp (Exim 4.69) (envelope-from ) id 1SDUFT-0005le-Lv for geb-bug-gnu-emacs@m.gmane.org; Fri, 30 Mar 2012 07:19:43 +0200 Original-Received: from localhost ([::1]:48440 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1SDUFS-0002aC-W3 for geb-bug-gnu-emacs@m.gmane.org; Fri, 30 Mar 2012 01:19:42 -0400 Original-Received: from eggs.gnu.org ([208.118.235.92]:38712) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1SDUFP-0002a4-By for bug-gnu-emacs@gnu.org; Fri, 30 Mar 2012 01:19:40 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1SDUFN-0004TQ-ER for bug-gnu-emacs@gnu.org; Fri, 30 Mar 2012 01:19:38 -0400 Original-Received: from [140.186.70.43] (port=38998 helo=debbugs.gnu.org) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1SDUFN-0004SU-Ao for bug-gnu-emacs@gnu.org; Fri, 30 Mar 2012 01:19:37 -0400 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.72) (envelope-from ) id 1SDUjl-0005l6-RE for bug-gnu-emacs@gnu.org; Fri, 30 Mar 2012 01:51:01 -0400 X-Loop: help-debbugs@gnu.org Resent-From: Thierry Volpiatto Original-Sender: debbugs-submit-bounces@debbugs.gnu.org Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Fri, 30 Mar 2012 05:51:01 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: report 11130 X-GNU-PR-Package: emacs X-GNU-PR-Keywords: patch X-Debbugs-Original-To: bug-gnu-emacs@gnu.org Original-Received: via spool by submit@debbugs.gnu.org id=B.133308663122095 (code B ref -1); Fri, 30 Mar 2012 05:51:01 +0000 Original-Received: (at submit) by debbugs.gnu.org; 30 Mar 2012 05:50:31 +0000 Original-Received: from localhost ([127.0.0.1]:45830 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.72) (envelope-from ) id 1SDUjG-0005kJ-Bi for submit@debbugs.gnu.org; Fri, 30 Mar 2012 01:50:31 -0400 Original-Received: from eggs.gnu.org ([208.118.235.92]:54122) by debbugs.gnu.org with esmtp (Exim 4.72) (envelope-from ) id 1SDUin-0005jJ-4u for submit@debbugs.gnu.org; Fri, 30 Mar 2012 01:50:28 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1SDUEG-0004LJ-B9 for submit@debbugs.gnu.org; Fri, 30 Mar 2012 01:18:29 -0400 Original-Received: from lists.gnu.org ([208.118.235.17]:44115) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1SDUEG-0004LE-7b for submit@debbugs.gnu.org; Fri, 30 Mar 2012 01:18:28 -0400 Original-Received: from eggs.gnu.org ([208.118.235.92]:45370) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1SDUEE-0002UN-5b for bug-gnu-emacs@gnu.org; Fri, 30 Mar 2012 01:18:27 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1SDUEB-0004Kq-S8 for bug-gnu-emacs@gnu.org; Fri, 30 Mar 2012 01:18:25 -0400 Original-Received: from plane.gmane.org ([80.91.229.3]:33201) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1SDUEB-0004Kj-HZ for bug-gnu-emacs@gnu.org; Fri, 30 Mar 2012 01:18:23 -0400 Original-Received: from list by plane.gmane.org with local (Exim 4.69) (envelope-from ) id 1SDUE7-0004Ix-UJ for bug-gnu-emacs@gnu.org; Fri, 30 Mar 2012 07:18:19 +0200 Original-Received: from lbe83-2-78-243-104-167.fbx.proxad.net ([78.243.104.167]) by main.gmane.org with esmtp (Gmexim 0.1 (Debian)) id 1AlnuQ-0007hv-00 for ; Fri, 30 Mar 2012 07:18:19 +0200 Original-Received: from thierry.volpiatto by lbe83-2-78-243-104-167.fbx.proxad.net with local (Gmexim 0.1 (Debian)) id 1AlnuQ-0007hv-00 for ; Fri, 30 Mar 2012 07:18:19 +0200 X-Injected-Via-Gmane: http://gmane.org/ Original-Lines: 143 Original-X-Complaints-To: usenet@dough.gmane.org X-Gmane-NNTP-Posting-Host: lbe83-2-78-243-104-167.fbx.proxad.net User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/24.0.94 (gnu/linux) Cancel-Lock: sha1:Deb7HrUihtKT6h4fAEKoW4kLHUA= X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.6 (newer, 3) X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.13 Precedence: list X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.6 (newer, 2) X-Received-From: 140.186.70.43 X-BeenThere: bug-gnu-emacs@gnu.org List-Id: "Bug reports for GNU Emacs, the Swiss army knife of text editors" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Original-Sender: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Xref: news.gmane.org gmane.emacs.bugs:58312 Archived-At: --=-=-= Content-Type: text/plain Hi, I reopen this as it seem it is not fixed. (Moved from emacs-dev list) I attach the patch again here, please review and try it. --=-=-= Content-Type: text/x-diff Content-Disposition: attachment; filename=patch-r119231.patch Content-Description: bugfix # HG changeset patch # User Thierry Volpiatto # Date 1333042420 -7200 # Node ID c2de4670a69cefd92095caca612f8b1e4fd0c217 # Parent 0c4996976cc3ded487b93f71a27641a48c127767 * lisp/files.el (copy-directory): Check if file is a directory but a symlink. diff --git a/lisp/dired-aux.el b/lisp/dired-aux.el --- a/lisp/dired-aux.el +++ b/lisp/dired-aux.el @@ -1264,7 +1264,8 @@ (defun dired-copy-file-recursive (from to ok-flag &optional preserve-time top recursive) - (when (file-subdir-of-p to from) + (when (and (eq t (car (file-attributes from))) + (file-subdir-of-p to from)) (error "Cannot copy `%s' into its subdirectory `%s'" from to)) (let ((attrs (file-attributes from))) (if (and recursive @@ -1452,10 +1453,14 @@ (eq file-creator 'dired-copy-file)) (setq to destname)) ;; If DESTNAME and FROM are the same directory or - ;; If DESTNAME is a subdirectory of FROM, return error. - (and (file-subdir-of-p destname from) - (error "Cannot copy `%s' into its subdirectory `%s'" - from to))) + ;; If DESTNAME is a subdirectory of FROM, not a symlink, + ;; and the method in use is copying return error. + (when (and (eq t ; A dir but not a symlink. + (car (file-attributes destname))) + (eq file-creator 'dired-copy-file) + (file-subdir-of-p destname from)) + (error "Here:Cannot copy `%s' into its subdirectory `%s'" + from to))) (condition-case err (progn (funcall file-creator from to dired-overwrite-confirmed) 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))))) --=-=-= Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit --8<---------------cut here---------------start------------->8--- 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. 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. 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! 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. Michael --8<---------------cut here---------------end--------------->8--- -- Thierry Get my Gnupg key: gpg --keyserver pgp.mit.edu --recv-keys 59F29997 --=-=-=--