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, 15 Jan 2012 20:09:06 +0100 Message-ID: <8762gckckt.fsf@gmail.com> References: <87mx9su32g.fsf@web.de> <87sjjkfvwt.fsf@gmail.com> <8362ggkquq.fsf@gnu.org> <87lipcrlga.fsf@gmail.com> <87fwfkc4pn.fsf@gmx.de> <87fwfjsw8t.fsf@gmail.com> <87aa5rdazl.fsf@gmx.de> <87d3anogf5.fsf@gmail.com> <011AEED9E81C4DEFA6B1E03B0F57F28F@us.oracle.com> <878vlbljnc.fsf@gmx.de> <8739bj8mu1.fsf@gmail.com> <87fwfjo24c.fsf@gmx.de> <87pqen76p4.fsf@gmail.com> <83fwfik92e.fsf@gnu.org> <87mx9q1sz7.fsf@gmail.com> <87vcodm8ns.fsf@gmx.de> <87pqekopb5.fsf@gmail.com> <87hazwoost.fsf@gmail.com> <87ty3w9639.fsf@gmx.de> NNTP-Posting-Host: lo.gmane.org Mime-Version: 1.0 Content-Type: text/plain X-Trace: dough.gmane.org 1326654623 5322 80.91.229.12 (15 Jan 2012 19:10:23 GMT) X-Complaints-To: usenet@dough.gmane.org NNTP-Posting-Date: Sun, 15 Jan 2012 19:10: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 Jan 15 20:10:19 2012 Return-path: Envelope-to: geb-bug-gnu-emacs@m.gmane.org Original-Received: from lists.gnu.org ([140.186.70.17]) by lo.gmane.org with esmtp (Exim 4.69) (envelope-from ) id 1RmVT8-0007ea-Gj for geb-bug-gnu-emacs@m.gmane.org; Sun, 15 Jan 2012 20:10:18 +0100 Original-Received: from localhost ([::1]:56564 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1RmVT7-0001AU-QT for geb-bug-gnu-emacs@m.gmane.org; Sun, 15 Jan 2012 14:10:17 -0500 Original-Received: from eggs.gnu.org ([140.186.70.92]:53906) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1RmVT4-0001AC-4T for bug-gnu-emacs@gnu.org; Sun, 15 Jan 2012 14:10:15 -0500 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1RmVT2-0001gS-NY for bug-gnu-emacs@gnu.org; Sun, 15 Jan 2012 14:10:14 -0500 Original-Received: from debbugs.gnu.org ([140.186.70.43]:35985) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1RmVT2-0001gO-Lo for bug-gnu-emacs@gnu.org; Sun, 15 Jan 2012 14:10:12 -0500 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.72) (envelope-from ) id 1RmVTq-0005pV-CR for bug-gnu-emacs@gnu.org; Sun, 15 Jan 2012 14:11: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, 15 Jan 2012 19:11: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: Original-Received: via spool by 10489-submit@debbugs.gnu.org id=B10489.132665460622344 (code B ref 10489); Sun, 15 Jan 2012 19:11:02 +0000 Original-Received: (at 10489) by debbugs.gnu.org; 15 Jan 2012 19:10:06 +0000 Original-Received: from localhost ([127.0.0.1]:58891 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.72) (envelope-from ) id 1RmVSv-0005oL-Ue for submit@debbugs.gnu.org; Sun, 15 Jan 2012 14:10:06 -0500 Original-Received: from mail-wi0-f172.google.com ([209.85.212.172]:35220) by debbugs.gnu.org with esmtp (Exim 4.72) (envelope-from ) id 1RmVSs-0005nx-0l for 10489@debbugs.gnu.org; Sun, 15 Jan 2012 14:10:03 -0500 Original-Received: by wics10 with SMTP id s10so649198wic.3 for <10489@debbugs.gnu.org>; Sun, 15 Jan 2012 11:09:11 -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=KivFnjZ/sKtuPjKu0HLzgGb3UxQdyB1lRstK+pk6HmU=; b=fpr50RXnAkFolOPfza3FEXADg/Bs+3iC1OFtlfZxudpxEuap5XMjPSepzVDv3FdJ5l 4ZOVh/31CBO4QLq5/5eFTPO5aJAyy6mXKiIyG38sKueM+VAG7jxCQlwlVeqcRVPXliDv VOl7kr8iEu6LxfHFwaD9yHSVeKmAEBud+YLHA= Original-Received: by 10.180.85.4 with SMTP id d4mr14607516wiz.0.1326654551446; Sun, 15 Jan 2012 11:09:11 -0800 (PST) Original-Received: from thierry-MM061 (86.78.88.79.rev.sfr.net. [79.88.78.86]) by mx.google.com with ESMTPS id fc6sm14933842wbb.16.2012.01.15.11.09.08 (version=TLSv1/SSLv3 cipher=OTHER); Sun, 15 Jan 2012 11:09:10 -0800 (PST) In-Reply-To: <87ty3w9639.fsf@gmx.de> (Michael Albinus's message of "Sun, 15 Jan 2012 19:24:42 +0100") User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/24.0.92 (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:55773 Archived-At: Michael Albinus writes: > Thierry Volpiatto writes: > >> Thierry Volpiatto writes: >> >>> Many examples given here, so if everybody is ok with The function given >>> by Drew, we could commit the attached patch to fix this bug: >> Note also that the bug is still here with this code >> when copying on same system "/sudo::/foo" to "/foo" > > One could also add it to Tramp for Emacs 24.1. But this sounds like a > new feature to me, and I would like to postpone it to Emacs 24.2. There > must be robust testing, if we start to handle such use cases. IMHO we should fix this bug for most use cases with a compare function maybe not perfect in many points but ok for most basic usages. The function shown by Drew and I put in last patch as you said isn't sufficient and fail in many cases even on local filesystem: (defun bmkp-same-file-p (file1 file2) "Return non-nil if FILE1 and FILE2 name the same file. If either name is not absolute, then it is expanded relative to `default-directory' for the test." (and (equal (file-remote-p file1) (file-remote-p file2)) (string= (file-truename (expand-file-name file1)) (file-truename (expand-file-name file2))))) (bmkp-same-file-p "~/Test" "/home/thierry/Test/") => nil That would be for Emacs24.1, and we could work on the real thing in tramp for 24.2 Here is my last work on this based on precedent example i sent and your last advices; it doesn't cover many use cases as you point before, test user, method etc... but works for all the use cases below: #+BEGIN_SRC emacs-lisp (defun file-equal-p (name1 name2) (if (or (file-remote-p name1) (file-remote-p name2)) (let* ((n1 (file-name-as-directory (expand-file-name name1))) (n2 (file-name-as-directory (expand-file-name name2))) (rhost1 (file-remote-p n1 'host)) (rhost2 (file-remote-p n2 'host)) (lname1 (file-remote-p n1 'localname)) (lname2 (file-remote-p n2 'localname)) rem-n1 rem-n2) (cond ((and rhost1 (not rhost2)) (setq rem-n1 (list (cons rhost1 (file-truename lname1)))) (setq rem-n2 (list (cons (system-name) (file-truename n2))))) ((and (not rhost1) rhost2) (setq rem-n1 (list (cons (system-name) (file-truename n1)))) (setq rem-n2 (list (cons rhost2 (file-truename lname2))))) ((and rhost1 rhost2) (setq rem-n1 (list (cons rhost1 (file-truename lname1)))) (setq rem-n2 (list (cons rhost2 (file-truename lname2)))))) (loop for (x1 . y1) in rem-n1 for (x2 . y2) in rem-n2 always (and (equal x1 x2) (equal y1 y2)))) (string= (file-name-as-directory (file-truename (expand-file-name name1))) (file-name-as-directory (file-truename (expand-file-name name2)))))) #+END_SRC --8<---------------cut here---------------start------------->8--- (dont-compile (when (fboundp 'expectations) (expectations (desc "Local file name comparison: Symlink<=>truefile") (expect t (file-equal-p "~/.emacs.el" "~/.emacs.d/emacs-config-laptop/.emacs.el")) (desc "Local file name comparison") (expect t (file-equal-p "/home/thierry/Test" "~/Test")) (expect t (file-equal-p "/home/thierry/Test" "~/Test/")) (expect nil (file-equal-p "/home/thierry/Test" "/home/thierry/tmp/Test")) (expect t (file-equal-p "./save-scratch.el" "~/labo/tmp/save-scratch.el")) (expect nil (file-equal-p "/home/thierry/tmp" "/tmp")) (expect nil (file-equal-p "/home/thierry/test" "/home/thierry/Test")) (desc "Sudo file against local") (expect nil (file-equal-p "/sudo::/home/thierry/Test" "/sudo::~/Test")) (expect t (file-equal-p "/sudo::/home/thierry/Test" "~/Test")) (desc "Remote file name comparison with different methods") (expect t (file-equal-p "/ssh:thievol:/home/thierry/Test" "/scpc:thievol:/home/thierry/Test")) (desc "Remote file name with localfile") (expect nil (file-equal-p "/ssh:thievol:/home/thierry/Test" "/home/thierry/Test")) (desc "Remote file name comparison with same methods same files") (expect t (file-equal-p "/scpc:thievol:/home/thierry/Test" "/scpc:thievol:/home/thierry/Test"))))) --8<---------------cut here---------------end--------------->8--- 22 expectations, 0 failures, 0 errors Expectations finished at Sun Jan 15 20:04:10 2012 -- Thierry Get my Gnupg key: gpg --keyserver pgp.mit.edu --recv-keys 59F29997