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#10489: 24.0.92; dired-do-copy may create infinite directory hierarchy Date: Tue, 28 Feb 2012 08:14:28 +0100 Message-ID: <87zkc3xwdn.fsf@gmail.com> References: <87mx9su32g.fsf@web.de> <87haygx97t.fsf@gmx.de> <87aa47rj6z.fsf@gmail.com> <878vjrxpej.fsf@gmx.de> <87pqd3i8ky.fsf@gmail.com> <87ipiuvsbw.fsf@gmx.de> <87k439gyu5.fsf@gmail.com> <87fwdwhizm.fsf@gmail.com> <87bookhfcn.fsf@gmail.com> <87aa44o7qo.fsf@gmail.com> <87ty2c490n.fsf@gmail.com> <87r4xgkt2b.fsf@gmail.com> <87obskum9i.fsf@gmx.de> <874nuc9bao.fsf@gmail.com> <874nubzdsu.fsf@gmail.com> NNTP-Posting-Host: plane.gmane.org Mime-Version: 1.0 Content-Type: text/plain X-Trace: dough.gmane.org 1330413393 22435 80.91.229.3 (28 Feb 2012 07:16:33 GMT) X-Complaints-To: usenet@dough.gmane.org NNTP-Posting-Date: Tue, 28 Feb 2012 07:16:33 +0000 (UTC) To: 10489@debbugs.gnu.org Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Tue Feb 28 08:16:32 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 1S2HIW-0004Ce-9t for geb-bug-gnu-emacs@m.gmane.org; Tue, 28 Feb 2012 08:16:32 +0100 Original-Received: from localhost ([::1]:52244 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1S2HIV-0002Ac-Ex for geb-bug-gnu-emacs@m.gmane.org; Tue, 28 Feb 2012 02:16:31 -0500 Original-Received: from eggs.gnu.org ([208.118.235.92]:41732) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1S2HIS-0002AU-29 for bug-gnu-emacs@gnu.org; Tue, 28 Feb 2012 02:16:29 -0500 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1S2HIL-0005E5-OR for bug-gnu-emacs@gnu.org; Tue, 28 Feb 2012 02:16:27 -0500 Original-Received: from debbugs.gnu.org ([140.186.70.43]:58753) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1S2HIL-0005Dz-Jr for bug-gnu-emacs@gnu.org; Tue, 28 Feb 2012 02:16:21 -0500 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.72) (envelope-from ) id 1S2HKv-000780-HO for bug-gnu-emacs@gnu.org; Tue, 28 Feb 2012 02:19:01 -0500 X-Loop: help-debbugs@gnu.org In-Reply-To: <87mx9su32g.fsf@web.de> Resent-From: Thierry Volpiatto Original-Sender: debbugs-submit-bounces@debbugs.gnu.org Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Tue, 28 Feb 2012 07:19:01 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 10489 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.133041349827345 (code B ref -1); Tue, 28 Feb 2012 07:19:01 +0000 Original-Received: (at submit) by debbugs.gnu.org; 28 Feb 2012 07:18:18 +0000 Original-Received: from localhost ([127.0.0.1]:60650 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.72) (envelope-from ) id 1S2HKD-00075s-Dj for submit@debbugs.gnu.org; Tue, 28 Feb 2012 02:18:17 -0500 Original-Received: from eggs.gnu.org ([208.118.235.92]:45108) by debbugs.gnu.org with esmtp (Exim 4.72) (envelope-from ) id 1S2HK1-00075C-Rg for submit@debbugs.gnu.org; Tue, 28 Feb 2012 02:18:06 -0500 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1S2HGu-00054w-N9 for submit@debbugs.gnu.org; Tue, 28 Feb 2012 02:14:54 -0500 Original-Received: from lists.gnu.org ([208.118.235.17]:47710) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1S2HGu-00054s-Jn for submit@debbugs.gnu.org; Tue, 28 Feb 2012 02:14:52 -0500 Original-Received: from eggs.gnu.org ([208.118.235.92]:41624) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1S2HGs-00020f-Ot for bug-gnu-emacs@gnu.org; Tue, 28 Feb 2012 02:14:52 -0500 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1S2HGq-00054W-E4 for bug-gnu-emacs@gnu.org; Tue, 28 Feb 2012 02:14:50 -0500 Original-Received: from plane.gmane.org ([80.91.229.3]:34353) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1S2HGq-00054P-3b for bug-gnu-emacs@gnu.org; Tue, 28 Feb 2012 02:14:48 -0500 Original-Received: from list by plane.gmane.org with local (Exim 4.69) (envelope-from ) id 1S2HGl-00037l-LU for bug-gnu-emacs@gnu.org; Tue, 28 Feb 2012 08:14:43 +0100 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 ; Tue, 28 Feb 2012 08:14:43 +0100 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 ; Tue, 28 Feb 2012 08:14:43 +0100 X-Injected-Via-Gmane: http://gmane.org/ Original-Lines: 74 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:4/Hrz8GG9aQbQyhr/WlKel6EQi4= 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:57342 Archived-At: Thierry Volpiatto writes: > Thierry Volpiatto writes: > >> Stefan Monnier writes: >> >>>>> If you don't create "test1" and file-subdir-of-p is unable to handle a >>>>> non--existing directory,I don't understand how you want to do. >>>> I was saying that files-equal-p returns unexpected results in case both >>>> files do not exist. I haven't spoken about file-subdir-of-p. >>> >>> Exactly. I don't think noexist is needed for subdir-p (it should accept >>> a non-existing dir for the `dir1' argument, without any need for >>> a noexist arg and it should reject a non-existing dir2), but I can live >>> with it, but file-equal-p only makes sense for existing files and should >>> not have a `noexist' argument. >> Ah! yes, thats sound good. >> Just need to remove check of file-directory-p for dir1 in f-subdir-of-p. > Note that the last check: > (files-equal-p (file-truename root) dir2) > can be: > (files-equal-p root dir2) > file-truename is not needed here. Here the patch: --8<---------------cut here---------------start------------->8--- diff --git a/lisp/files.el b/lisp/files.el --- a/lisp/files.el +++ b/lisp/files.el @@ -4999,13 +4999,12 @@ (defun file-subdir-of-p (dir1 dir2) "Return non-nil if DIR1 is a subdirectory of DIR2. A directory is considered to be a subdirectory of itself. -Return nil if DIR1 or DIR2 are not existing directories." +Return nil if top directory DIR2 is not an existing directory." (let ((handler (or (find-file-name-handler dir1 'file-subdir-of-p) (find-file-name-handler dir2 'file-subdir-of-p)))) (if handler (funcall handler 'file-subdir-of-p dir1 dir2) - (when (and (file-directory-p dir1) - (file-directory-p dir2)) + (when (file-directory-p dir2) ; Top dir must exist. (setq dir1 (file-truename dir1) dir2 (file-truename dir2)) (let ((ls1 (or (split-string dir1 "/" t) '("/"))) @@ -5019,7 +5018,7 @@ (setq ls1 (cdr ls1) ls2 (cdr ls2))) (unless mismatch - (files-equal-p (file-truename root) dir2))))))) + (files-equal-p root dir2))))))) (defun copy-directory (directory newname &optional keep-time parents copy-contents) "Copy DIRECTORY to NEWNAME. Both args must be strings. @@ -5065,12 +5064,7 @@ (cond ((not (file-directory-p newname)) ;; If NEWNAME is not an existing directory, create it; ;; that is where we will copy the files of DIRECTORY. - (make-directory newname parents) - ;; `file-subdir-of-p' doesn't handle non--existing directories, - ;; so double check now if NEWNAME is not a subdir of DIRECTORY. - (and (file-subdir-of-p newname directory) - (error "Cannot copy `%s' into its subdirectory `%s'" - directory newname))) + (make-directory newname parents)) ;; If NEWNAME is an existing directory and COPY-CONTENTS ;; is nil, copy into NEWNAME/[DIRECTORY-BASENAME]. ((not copy-contents) --8<---------------cut here---------------end--------------->8--- -- Thierry Get my Gnupg key: gpg --keyserver pgp.mit.edu --recv-keys 59F29997