From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!.POSTED!not-for-mail From: Paul Eggert Newsgroups: gmane.emacs.bugs Subject: bug#28520: bug#28483: 26.0.50; copy-directory does not create directories Date: Wed, 20 Sep 2017 11:59:37 -0700 Organization: UCLA Computer Science Department Message-ID: References: <972c8b3c-f72d-d447-78b3-cc7fcf6234e5@cs.ucla.edu> <83mv5pfw5b.fsf@gnu.org> NNTP-Posting-Host: blaine.gmane.org Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="------------76E760785E419C48D3063ADA" X-Trace: blaine.gmane.org 1505934020 20617 195.159.176.226 (20 Sep 2017 19:00:20 GMT) X-Complaints-To: usenet@blaine.gmane.org NNTP-Posting-Date: Wed, 20 Sep 2017 19:00:20 +0000 (UTC) User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:52.0) Gecko/20100101 Thunderbird/52.3.0 Cc: 28483@debbugs.gnu.org, Adam Plaice , 28520-done@debbugs.gnu.org, aaronjensen@gmail.com, Tino Calancha To: Eli Zaretskii Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Wed Sep 20 21:00:14 2017 Return-path: Envelope-to: geb-bug-gnu-emacs@m.gmane.org Original-Received: from lists.gnu.org ([208.118.235.17]) by blaine.gmane.org with esmtp (Exim 4.84_2) (envelope-from ) id 1dukEI-000553-1Q for geb-bug-gnu-emacs@m.gmane.org; Wed, 20 Sep 2017 21:00:14 +0200 Original-Received: from localhost ([::1]:50227 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dukEP-0000nT-Ch for geb-bug-gnu-emacs@m.gmane.org; Wed, 20 Sep 2017 15:00:21 -0400 Original-Received: from eggs.gnu.org ([2001:4830:134:3::10]:40260) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dukEC-0000gM-GY for bug-gnu-emacs@gnu.org; Wed, 20 Sep 2017 15:00:14 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1dukE8-0001yR-A9 for bug-gnu-emacs@gnu.org; Wed, 20 Sep 2017 15:00:08 -0400 Original-Received: from debbugs.gnu.org ([208.118.235.43]:41816) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1dukE8-0001xp-6e for bug-gnu-emacs@gnu.org; Wed, 20 Sep 2017 15:00:04 -0400 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1dukE7-0001In-Ry for bug-gnu-emacs@gnu.org; Wed, 20 Sep 2017 15:00:03 -0400 Resent-From: Paul Eggert Original-Sender: "Debbugs-submit" Resent-To: bug-gnu-emacs@gnu.org Resent-Date: Wed, 20 Sep 2017 19:00:03 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: cc-closed 28520 X-GNU-PR-Package: emacs X-GNU-PR-Keywords: confirmed Mail-Followup-To: 28520@debbugs.gnu.org, eggert@cs.ucla.edu, plaice.adam+lists@gmail.com Original-Received: via spool by 28520-done@debbugs.gnu.org id=D28520.15059339894939 (code D ref 28520); Wed, 20 Sep 2017 19:00:03 +0000 Original-Received: (at 28520-done) by debbugs.gnu.org; 20 Sep 2017 18:59:49 +0000 Original-Received: from localhost ([127.0.0.1]:50494 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1dukDt-0001HW-DE for submit@debbugs.gnu.org; Wed, 20 Sep 2017 14:59:49 -0400 Original-Received: from zimbra.cs.ucla.edu ([131.179.128.68]:56394) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1dukDp-0001H7-7H; Wed, 20 Sep 2017 14:59:45 -0400 Original-Received: from localhost (localhost [127.0.0.1]) by zimbra.cs.ucla.edu (Postfix) with ESMTP id 3C64B160AEB; Wed, 20 Sep 2017 11:59:39 -0700 (PDT) Original-Received: from zimbra.cs.ucla.edu ([127.0.0.1]) by localhost (zimbra.cs.ucla.edu [127.0.0.1]) (amavisd-new, port 10032) with ESMTP id GO5z218rFOvq; Wed, 20 Sep 2017 11:59:38 -0700 (PDT) Original-Received: from localhost (localhost [127.0.0.1]) by zimbra.cs.ucla.edu (Postfix) with ESMTP id 4E639160BF0; Wed, 20 Sep 2017 11:59:38 -0700 (PDT) X-Virus-Scanned: amavisd-new at zimbra.cs.ucla.edu Original-Received: from zimbra.cs.ucla.edu ([127.0.0.1]) by localhost (zimbra.cs.ucla.edu [127.0.0.1]) (amavisd-new, port 10026) with ESMTP id 62g8EZC72wKQ; Wed, 20 Sep 2017 11:59:38 -0700 (PDT) Original-Received: from Penguin.CS.UCLA.EDU (Penguin.CS.UCLA.EDU [131.179.64.200]) by zimbra.cs.ucla.edu (Postfix) with ESMTPSA id 2DC3B160AEB; Wed, 20 Sep 2017 11:59:38 -0700 (PDT) In-Reply-To: <83mv5pfw5b.fsf@gnu.org> Content-Language: en-US X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-Received-From: 208.118.235.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" Xref: news.gmane.org gmane.emacs.bugs:137185 Archived-At: This is a multi-part message in MIME format. --------------76E760785E419C48D3063ADA Content-Type: text/plain; charset=utf-8; format=flowed Content-Transfer-Encoding: 7bit On 09/20/2017 04:26 AM, Eli Zaretskii wrote: > I think the problem is in this line: > > (cond > ((eq filetype t) ; Directory but not a symlink. > (copy-directory file newname keep-time parents)) <<<<<<<<<<< > > Instead of 'newname', there should be (file-name-as-directory newname) > there. I think. Thanks for diagnosing the problem and for the fix. That fix should work, and I think we can improve on it slightly by using (copy-directory file target keep-time parents t), as this makes the cond branch more parallel with the other alternatives and avoids a call to file-name-as-directory. So I installed the attached patch into the emacs-26 branch to do that, and to add a test case for this bug. This patch should also fix Bug#28520 "Dired recursive copy of directory fails", so I'll CC: that bug report and boldly close it. PS. Sorry, Adam, for misspelling your first name in the commit message. I'll try to remember to fix that when it spills out into the ChangeLog file. --------------76E760785E419C48D3063ADA Content-Type: text/x-patch; name="0001-Fix-new-copy-directory-bug-with-empty-dirs.patch" Content-Transfer-Encoding: 7bit Content-Disposition: attachment; filename="0001-Fix-new-copy-directory-bug-with-empty-dirs.patch" >From b4531a78ded7efb0c133763b5efe1f4dab1aa4de Mon Sep 17 00:00:00 2001 From: Paul Eggert Date: Wed, 20 Sep 2017 11:49:12 -0700 Subject: [PATCH] Fix new copy-directory bug with empty dirs Problem reported by Afdam Plaice (Bug#28520) and by Eli Zaretskii (Bug#28483#34). This is another bug that I introduced in my recent copy-directory changes. * lisp/files.el (copy-directory): Work with empty subdirectories, too. * test/lisp/files-tests.el (files-tests--copy-directory): Test for this bug. --- lisp/files.el | 2 +- test/lisp/files-tests.el | 7 ++++++- 2 files changed, 7 insertions(+), 2 deletions(-) diff --git a/lisp/files.el b/lisp/files.el index 0c30d40c13..f0a1f2380d 100644 --- a/lisp/files.el +++ b/lisp/files.el @@ -5564,7 +5564,7 @@ copy-directory (filetype (car (file-attributes file)))) (cond ((eq filetype t) ; Directory but not a symlink. - (copy-directory file newname keep-time parents)) + (copy-directory file target keep-time parents t)) ((stringp filetype) ; Symbolic link (make-symbolic-link filetype target t)) ((copy-file file target t keep-time))))) diff --git a/test/lisp/files-tests.el b/test/lisp/files-tests.el index f2a9a32180..285a884b69 100644 --- a/test/lisp/files-tests.el +++ b/test/lisp/files-tests.el @@ -399,11 +399,16 @@ files-tests--with-temp-file (dirname (file-name-as-directory dir)) (source (concat dirname "source")) (dest (concat dirname "dest/new/directory/")) - (file (concat (file-name-as-directory source) "file"))) + (file (concat (file-name-as-directory source) "file")) + (source2 (concat dirname "source2")) + (dest2 (concat dirname "dest/new2"))) (make-directory source) (write-region "" nil file) (copy-directory source dest t t t) (should (file-exists-p (concat dest "file"))) + (make-directory (concat (file-name-as-directory source2) "a") t) + (copy-directory source2 dest2) + (should (file-directory-p (concat (file-name-as-directory dest2) "a"))) (delete-directory dir 'recursive))) (provide 'files-tests) -- 2.13.5 --------------76E760785E419C48D3063ADA--