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 09:15:25 +0100 Message-ID: <87vcmrxtk2.fsf@gmail.com> References: <87mx9su32g.fsf@web.de> <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> <87zkc3xwdn.fsf@gmail.com> <87k437o1hm.fsf@gmx.de> NNTP-Posting-Host: plane.gmane.org Mime-Version: 1.0 Content-Type: text/plain X-Trace: dough.gmane.org 1330417071 14751 80.91.229.3 (28 Feb 2012 08:17:51 GMT) X-Complaints-To: usenet@dough.gmane.org NNTP-Posting-Date: Tue, 28 Feb 2012 08:17:51 +0000 (UTC) Cc: 10489@debbugs.gnu.org To: Michael Albinus Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Tue Feb 28 09:17:48 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 1S2IFo-00073g-8u for geb-bug-gnu-emacs@m.gmane.org; Tue, 28 Feb 2012 09:17:48 +0100 Original-Received: from localhost ([::1]:54202 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1S2IFn-0008Kz-IS for geb-bug-gnu-emacs@m.gmane.org; Tue, 28 Feb 2012 03:17:47 -0500 Original-Received: from eggs.gnu.org ([208.118.235.92]:46857) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1S2IFV-0008Ip-HL for bug-gnu-emacs@gnu.org; Tue, 28 Feb 2012 03:17:45 -0500 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1S2IFO-0006Q6-VC for bug-gnu-emacs@gnu.org; Tue, 28 Feb 2012 03:17:29 -0500 Original-Received: from debbugs.gnu.org ([140.186.70.43]:58822) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1S2IFO-0006Py-O9 for bug-gnu-emacs@gnu.org; Tue, 28 Feb 2012 03:17:22 -0500 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.72) (envelope-from ) id 1S2IHy-00005W-GD for bug-gnu-emacs@gnu.org; Tue, 28 Feb 2012 03:20:02 -0500 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: Tue, 28 Feb 2012 08:20:02 +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 Original-Received: via spool by 10489-submit@debbugs.gnu.org id=B10489.133041717432749 (code B ref 10489); Tue, 28 Feb 2012 08:20:02 +0000 Original-Received: (at 10489) by debbugs.gnu.org; 28 Feb 2012 08:19:34 +0000 Original-Received: from localhost ([127.0.0.1]:60704 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.72) (envelope-from ) id 1S2IHR-0008Vq-24 for submit@debbugs.gnu.org; Tue, 28 Feb 2012 03:19:34 -0500 Original-Received: from mail-wi0-f172.google.com ([209.85.212.172]:41604) by debbugs.gnu.org with esmtp (Exim 4.72) (envelope-from ) id 1S2IGf-0008U6-84 for 10489@debbugs.gnu.org; Tue, 28 Feb 2012 03:18:47 -0500 Original-Received: by wicr5 with SMTP id r5so1239673wic.3 for <10489@debbugs.gnu.org>; Tue, 28 Feb 2012 00:15:29 -0800 (PST) Received-SPF: pass (google.com: domain of thierry.volpiatto@gmail.com designates 10.180.14.37 as permitted sender) client-ip=10.180.14.37; Authentication-Results: mr.google.com; spf=pass (google.com: domain of thierry.volpiatto@gmail.com designates 10.180.14.37 as permitted sender) smtp.mail=thierry.volpiatto@gmail.com; dkim=pass header.i=thierry.volpiatto@gmail.com Original-Received: from mr.google.com ([10.180.14.37]) by 10.180.14.37 with SMTP id m5mr24506126wic.19.1330416929970 (num_hops = 1); Tue, 28 Feb 2012 00:15:29 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=from:to:cc:subject:references:date:in-reply-to:message-id :user-agent:mime-version:content-type; bh=9cwc4L8mjTTDqeQmasO7u3f2siz8+SH+Z74zsZ7oYe0=; b=xtrs9jzWyiw5HMT+E/uGaJhRN815gET23E8QZg28Fxoh76sSs6BlSJJdtsuBHgSoW6 yjhkvUTzY0ONfv+2f4DRFVN1zX9KewFoFXtax0tNRa/qd1hXxoi/22XHMhU7762OuUi7 ktXM8pmJCBqTz4Z+zEtZq6W0QB0q7thY+ytPc= Original-Received: by 10.180.14.37 with SMTP id m5mr19263678wic.19.1330416929874; Tue, 28 Feb 2012 00:15:29 -0800 (PST) Original-Received: from thierry-MM061 (lbe83-2-78-243-104-167.fbx.proxad.net. [78.243.104.167]) by mx.google.com with ESMTPS id d7sm67479880wiz.6.2012.02.28.00.15.27 (version=TLSv1/SSLv3 cipher=OTHER); Tue, 28 Feb 2012 00:15:28 -0800 (PST) In-Reply-To: <87k437o1hm.fsf@gmx.de> (Michael Albinus's message of "Tue, 28 Feb 2012 08:34:13 +0100") User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/24.0.94 (gnu/linux) 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:57345 Archived-At: Hi Michael, Michael Albinus writes: > Thierry Volpiatto writes: > >> Here the patch: > > `files-equal-p' still returns t for two non-existing files. Shall be > fixed too. Fixed. > Btw, this is the only primitive function which has the prefix "files-", > all other start with prefix "file-". Is this necessary? I wrote files because comparing two files, but I don't care of this, just rename it to file- > (No it is not important, but if we want change it, we must do it before > the 24.1 release). --8<---------------cut here---------------start------------->8--- diff --git a/lisp/files.el b/lisp/files.el --- a/lisp/files.el +++ b/lisp/files.el @@ -4985,27 +4985,27 @@ directory 'full directory-files-no-dot-files-regexp))) (delete-directory-internal directory))))) -(defun files-equal-p (file1 file2) +(defun file-equal-p (file1 file2) "Return non-nil if FILE1 and FILE2 name the same file. Ordinary files are considered to be the same if `file-attributes' returns `equal' values for them." - (let ((handler (or (find-file-name-handler file1 'files-equal-p) - (find-file-name-handler file2 'files-equal-p)))) + (let ((handler (or (find-file-name-handler file1 'file-equal-p) + (find-file-name-handler file2 'file-equal-p)))) (if handler - (funcall handler 'files-equal-p file1 file2) - (equal (file-attributes (file-truename file1)) - (file-attributes (file-truename file2)))))) + (funcall handler 'file-equal-p file1 file2) + (let ((f1-attr (file-attributes (file-truename file1))) + (f2-attr (file-attributes (file-truename file2)))) + (and f1-attr f2-attr (equal f1-attr f2-attr)))))) (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 +5019,7 @@ (setq ls1 (cdr ls1) ls2 (cdr ls2))) (unless mismatch - (files-equal-p (file-truename root) dir2))))))) + (file-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 +5065,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