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: Sun, 26 Feb 2012 20:48:50 +0100 Message-ID: <87k439gyu5.fsf@gmail.com> References: <87mx9su32g.fsf@web.de> <87mx8b3nvb.fsf@gmail.com> <87pqd6wnvv.fsf@gmail.com> <87d395y1w0.fsf@gmail.com> <87zkc8x04p.fsf@gmail.com> <87vcmwwvk7.fsf@gmail.com> <834nugtwqf.fsf@gnu.org> <87r4xkwhky.fsf@gmail.com> <83vcmws3bs.fsf@gnu.org> <87ehtkwaiz.fsf@gmail.com> <87wr7cgsm3.fsf@gmx.de> <8762eww77b.fsf@gmail.com> <83pqd4roav.fsf@gnu.org> <87haygx97t.fsf@gmx.de> <87aa47rj6z.fsf@gmail.com> <878vjrxpej.fsf@gmx.de> <87pqd3i8ky.fsf@gmail.com> <87ipiuvsbw.fsf@gmx.de> NNTP-Posting-Host: plane.gmane.org Mime-Version: 1.0 Content-Type: text/plain X-Trace: dough.gmane.org 1330285763 25269 80.91.229.3 (26 Feb 2012 19:49:23 GMT) X-Complaints-To: usenet@dough.gmane.org NNTP-Posting-Date: Sun, 26 Feb 2012 19:49:23 +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 Sun Feb 26 20:49:22 2012 Return-path: Envelope-to: geb-bug-gnu-emacs@m.gmane.org Original-Received: from lists.gnu.org ([140.186.70.17]) by plane.gmane.org with esmtp (Exim 4.69) (envelope-from ) id 1S1k5x-0007Vp-QR for geb-bug-gnu-emacs@m.gmane.org; Sun, 26 Feb 2012 20:49:22 +0100 Original-Received: from localhost ([::1]:60744 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1S1k5x-0001kT-6S for geb-bug-gnu-emacs@m.gmane.org; Sun, 26 Feb 2012 14:49:21 -0500 Original-Received: from eggs.gnu.org ([208.118.235.92]:35838) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1S1k5t-0001kK-Ta for bug-gnu-emacs@gnu.org; Sun, 26 Feb 2012 14:49:18 -0500 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1S1k5s-0007BP-D2 for bug-gnu-emacs@gnu.org; Sun, 26 Feb 2012 14:49:17 -0500 Original-Received: from debbugs.gnu.org ([140.186.70.43]:56665) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1S1k5s-0007BF-7t for bug-gnu-emacs@gnu.org; Sun, 26 Feb 2012 14:49:16 -0500 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.72) (envelope-from ) id 1S1k8Y-0003Xr-I5 for bug-gnu-emacs@gnu.org; Sun, 26 Feb 2012 14:52: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: Sun, 26 Feb 2012 19:52: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.133028590613604 (code B ref 10489); Sun, 26 Feb 2012 19:52:02 +0000 Original-Received: (at 10489) by debbugs.gnu.org; 26 Feb 2012 19:51:46 +0000 Original-Received: from localhost ([127.0.0.1]:58562 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.72) (envelope-from ) id 1S1k8I-0003XM-CG for submit@debbugs.gnu.org; Sun, 26 Feb 2012 14:51:46 -0500 Original-Received: from mail-ww0-f46.google.com ([74.125.82.46]:36706) by debbugs.gnu.org with esmtp (Exim 4.72) (envelope-from ) id 1S1k8E-0003XE-Pu for 10489@debbugs.gnu.org; Sun, 26 Feb 2012 14:51:44 -0500 Original-Received: by wgbdq11 with SMTP id dq11so309093wgb.15 for <10489@debbugs.gnu.org>; Sun, 26 Feb 2012 11:48:55 -0800 (PST) Received-SPF: pass (google.com: domain of thierry.volpiatto@gmail.com designates 10.180.14.73 as permitted sender) client-ip=10.180.14.73; Authentication-Results: mr.google.com; spf=pass (google.com: domain of thierry.volpiatto@gmail.com designates 10.180.14.73 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.73]) by 10.180.14.73 with SMTP id n9mr21880709wic.16.1330285735161 (num_hops = 1); Sun, 26 Feb 2012 11:48:55 -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=XMJHeVfbrl8k2NUqfD8I5rSQOMKkEdWuE66qrikb68Y=; b=SFVeOArwFQwkzCNgMj6civtFyqsvG/TVcu+xTKIvuVyjTmI9fJm1uxOYOPGxWNL1gQ T+oa56FQN/dJcSk3SUncDOjXZzxHthgfYh4jc6SHcmIGiieMB0SgaBdhyb2Di63S0ObV 0+tOYRz/5HkP5YjU7YUw3hMw2EZgBoUo1Vfig= Original-Received: by 10.180.14.73 with SMTP id n9mr17461635wic.16.1330285735087; Sun, 26 Feb 2012 11:48:55 -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 ft8sm17223266wib.11.2012.02.26.11.48.52 (version=TLSv1/SSLv3 cipher=OTHER); Sun, 26 Feb 2012 11:48:54 -0800 (PST) In-Reply-To: <87ipiuvsbw.fsf@gmx.de> (Michael Albinus's message of "Sun, 26 Feb 2012 10:48:03 +0100") User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/24.0.93 (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:57262 Archived-At: Hi Michael, Michael Albinus writes: > Thierry Volpiatto writes: > >>> Btw, it might be useful if you could add documentation about >>> `files-equal-p' and `file-subdir-of-p' in doc/lispref/files.texi. >> I will have a look. > > Thanks. > > The implementation of `files-equal-p' returns t, Of course, (equal nil nil)=>t where nil and nil are the file-attributes of non--existing files. > if both FILE1 and FILE2 do not exist. Either it is a bug, or it must > be documented. We can fallback to string comparison when one of the file-attributes return nil. It would also make file-subdir-of-p working with non--existing dirnames. (with one optional arg): --8<---------------cut here---------------start------------->8--- diff --git a/lisp/files.el b/lisp/files.el --- a/lisp/files.el +++ b/lisp/files.el @@ -4991,10 +4991,16 @@ (find-file-name-handler file2 'files-equal-p)))) (if handler (funcall handler 'files-equal-p file1 file2) - (equal (file-attributes (file-truename file1)) - (file-attributes (file-truename file2)))))) - -(defun file-subdir-of-p (dir1 dir2) + (let ((f1-attr (file-attributes (file-truename file1))) + (f2-attr (file-attributes (file-truename file2)))) + (if (and f1-attr f2-attr) + (equal f1-attr f2-attr) + (string= (file-truename + (file-name-as-directory file1)) + (file-truename + (file-name-as-directory file2)))))))) + +(defun file-subdir-of-p (dir1 dir2 &optional noexist) "Return non-nil if DIR1 is a subdirectory of DIR2. Note that a directory is treated by this function as a subdirectory of itself. This function only works when its two arguments already exist, @@ -5003,8 +5009,9 @@ (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 (or noexist + (and (file-directory-p dir1) + (file-directory-p dir2))) (loop with f1 = (file-truename dir1) with f2 = (file-truename dir2) with ls1 = (or (split-string f1 "/" t) (list "/")) --8<---------------cut here---------------end--------------->8--- -- Thierry Get my Gnupg key: gpg --keyserver pgp.mit.edu --recv-keys 59F29997