GNU bug report logs - #5343
23.1.91; recursive directory copying is broken

Previous Next

Package: emacs;

Reported by: Stephen Berman <stephen.berman <at> gmx.net>

Date: Fri, 8 Jan 2010 23:24:02 UTC

Severity: normal

Done: Michael Albinus <michael.albinus <at> gmx.de>

Bug is archived. No further changes may be made.

To add a comment to this bug, you must first unarchive it, by sending
a message to control AT debbugs.gnu.org, with unarchive 5343 in the body.
You can then email your comments to 5343 AT debbugs.gnu.org in the normal way.

Toggle the display of automated, internal messages from the tracker.

View this report as an mbox folder, status mbox, maintainer mbox


Report forwarded to owner <at> debbugs.gnu.org, bug-gnu-emacs <at> gnu.org:
bug#5343; Package emacs. (Fri, 08 Jan 2010 23:24:02 GMT) Full text and rfc822 format available.

Acknowledgement sent to Stephen Berman <stephen.berman <at> gmx.net>:
New bug report received and forwarded. Copy sent to bug-gnu-emacs <at> gnu.org. (Fri, 08 Jan 2010 23:24:02 GMT) Full text and rfc822 format available.

Message #5 received at submit <at> debbugs.gnu.org (full text, mbox):

From: Stephen Berman <stephen.berman <at> gmx.net>
To: emacs-pretest-bug <at> gnu.org
Subject: 23.1.91; recursive directory copying is broken
Date: Sat, 09 Jan 2010 00:14:58 +0100
1. emacs -Q
2. Make a directory /tmp/test, add to it a file named "a" and a
   directory named "test", and add to /tmp/test/test a file named "b".
3. Type `M-x copy-directory RET /tmp/test RET ~ RET' to copy /tmp/test
   recursively to ~.
4. Type `C-x d' and at the prompt `~' to visit ~ in Dired, put the
   cursor on the directory "test" and type `i' to open "test" as a
   subdirectory.  This is the result:

  /home/steve/test:
  total used in directory 16 available 7794948
  -rw-r--r--  1 steve users    4 2010-01-08 23:57 a
  -rw-r--r--  1 steve users    7 2010-01-08 23:57 b

Using `C' in Dired gives the same broken result.  In Emacs 23.1
recursive directory copying by `C' in Dired (copy-directory does not
exist in 23.1) works correctly, i.e., shows this:

  /home/steve/test:
  total used in directory 16 available 7794944
  -rw-r--r--  1 steve users    4 2010-01-08 23:31 a
  drwxr-xr-x  2 steve users 4096 2010-01-09 00:06 test

  /home/steve/test/test:
  total used in directory 12 available 7794944
  -rw-r--r-- 1 steve users    7 2010-01-08 23:32 b


In GNU Emacs 23.1.91.1 (i686-pc-linux-gnu, GTK+ Version 2.18.1)
 of 2010-01-06 on escher
Windowing system distributor `The X.Org Foundation', version 11.0.10605000
Important settings:
  value of $LC_ALL: nil
  value of $LC_COLLATE: nil
  value of $LC_CTYPE: nil
  value of $LC_MESSAGES: nil
  value of $LC_MONETARY: nil
  value of $LC_NUMERIC: nil
  value of $LC_TIME: nil
  value of $LANG: en_US.UTF-8
  value of $XMODIFIERS: @im=local
  locale-coding-system: utf-8-unix
  default enable-multibyte-characters: t




Information forwarded to owner <at> debbugs.gnu.org, bug-gnu-emacs <at> gnu.org:
bug#5343; Package emacs. (Sat, 09 Jan 2010 22:25:02 GMT) Full text and rfc822 format available.

Message #8 received at 5343 <at> debbugs.gnu.org (full text, mbox):

From: Stephen Berman <stephen.berman <at> gmx.net>
To: 5343 <at> debbugs.gnu.org
Subject: Re: bug#5343: 23.1.91; recursive directory copying is broken
Date: Sat, 09 Jan 2010 22:53:58 +0100
On Sat, 09 Jan 2010 00:14:58 +0100 Stephen Berman <stephen.berman <at> gmx.net> wrote:

> 1. emacs -Q
> 2. Make a directory /tmp/test, add to it a file named "a" and a
>    directory named "test", and add to /tmp/test/test a file named "b".
> 3. Type `M-x copy-directory RET /tmp/test RET ~ RET' to copy /tmp/test
>    recursively to ~.
> 4. Type `C-x d' and at the prompt `~' to visit ~ in Dired, put the
>    cursor on the directory "test" and type `i' to open "test" as a
>    subdirectory.  This is the result:
>
>   /home/steve/test:
>   total used in directory 16 available 7794948
>   -rw-r--r--  1 steve users    4 2010-01-08 23:57 a
>   -rw-r--r--  1 steve users    7 2010-01-08 23:57 b

This is due to the following code in copy-directory:

    (if (and (file-directory-p newname)
             (not (string-equal (file-name-nondirectory directory)
    				(file-name-nondirectory newname))))
	(setq newname
	      (expand-file-name (file-name-nondirectory directory) newname)))

Specifically, the equality check prevents newname from being changed
from "home/steve/test" to "home/steve/test/test".  Removing this check,
as in the below patch, fixes the above breakage.  I don't see any real
problem this check prevents, but maybe I'm overlooking something.

Steve Berman

2010-01-09  Stephen Berman  <stephen.berman <at> gmx.net>

	* files.el (copy-directory): Don't check equality of source and
	target nondirectory names (bug#5343).

*** /tmp/ediff7644I7H	2010-01-09 22:23:07.000000000 +0100
--- /home/steve/bzr/emacs/quickfixes/lisp/files.el	2010-01-09 21:41:52.000000000 +0100
***************
*** 4714,4722 ****
        ;; Compute target name.
        (setq directory (directory-file-name (expand-file-name directory))
  	    newname   (directory-file-name (expand-file-name newname)))
!       (if (and (file-directory-p newname)
! 	       (not (string-equal (file-name-nondirectory directory)
! 				  (file-name-nondirectory newname))))
  	  (setq newname
  		(expand-file-name (file-name-nondirectory directory) newname)))
        (if (not (file-directory-p newname)) (make-directory newname parents))
--- 4714,4720 ----
        ;; Compute target name.
        (setq directory (directory-file-name (expand-file-name directory))
  	    newname   (directory-file-name (expand-file-name newname)))
!       (if (file-directory-p newname)
  	  (setq newname
  		(expand-file-name (file-name-nondirectory directory) newname)))
        (if (not (file-directory-p newname)) (make-directory newname parents))




Information forwarded to owner <at> debbugs.gnu.org, bug-gnu-emacs <at> gnu.org:
bug#5343; Package emacs. (Sun, 10 Jan 2010 02:16:02 GMT) Full text and rfc822 format available.

Message #11 received at 5343 <at> debbugs.gnu.org (full text, mbox):

From: Lennart Borgman <lennart.borgman <at> gmail.com>
To: Stephen Berman <stephen.berman <at> gmx.net>, 5343 <at> debbugs.gnu.org
Subject: Re: bug#5343: 23.1.91; recursive directory copying is broken
Date: Sun, 10 Jan 2010 03:14:48 +0100
On Sat, Jan 9, 2010 at 10:53 PM, Stephen Berman <stephen.berman <at> gmx.net> wrote:
> On Sat, 09 Jan 2010 00:14:58 +0100 Stephen Berman <stephen.berman <at> gmx.net> wrote:
>
>> 1. emacs -Q
>> 2. Make a directory /tmp/test, add to it a file named "a" and a
>>    directory named "test", and add to /tmp/test/test a file named "b".
>> 3. Type `M-x copy-directory RET /tmp/test RET ~ RET' to copy /tmp/test
>>    recursively to ~.
>> 4. Type `C-x d' and at the prompt `~' to visit ~ in Dired, put the
>>    cursor on the directory "test" and type `i' to open "test" as a
>>    subdirectory.  This is the result:
>>
>>   /home/steve/test:
>>   total used in directory 16 available 7794948
>>   -rw-r--r--  1 steve users    4 2010-01-08 23:57 a
>>   -rw-r--r--  1 steve users    7 2010-01-08 23:57 b
>
> This is due to the following code in copy-directory:
>
>    (if (and (file-directory-p newname)
>             (not (string-equal (file-name-nondirectory directory)
>                                (file-name-nondirectory newname))))
>        (setq newname
>              (expand-file-name (file-name-nondirectory directory) newname)))
>
> Specifically, the equality check prevents newname from being changed
> from "home/steve/test" to "home/steve/test/test".  Removing this check,
> as in the below patch, fixes the above breakage.  I don't see any real
> problem this check prevents, but maybe I'm overlooking something.


The check looks strange to me. I wonder if the intention really was to
prevent copying a directory tree into a subdirectory below itself? But
if so, should not the check be a bit different?


BTW, I looked at the variable `directory-files-no-dot-files-regexp'. I
minor issue, but should it not be

(defconst directory-files-no-dot-files-regexp
  "^\\(?:[^.]\\|\\.\\(?:[^.]\\|\\..\\)\\)"
  "Regexp of file names excluging \".\" an \"..\".")




Information forwarded to owner <at> debbugs.gnu.org, bug-gnu-emacs <at> gnu.org:
bug#5343; Package emacs. (Tue, 12 Jan 2010 22:09:02 GMT) Full text and rfc822 format available.

Message #14 received at 5343 <at> debbugs.gnu.org (full text, mbox):

From: Michael Albinus <michael.albinus <at> gmx.de>
To: Stephen Berman <stephen.berman <at> gmx.net>
Cc: 5343 <at> debbugs.gnu.org
Subject: Re: bug#5343: 23.1.91; recursive directory copying is broken
Date: Tue, 12 Jan 2010 23:07:31 +0100
Stephen Berman <stephen.berman <at> gmx.net> writes:

>> 1. emacs -Q
>> 2. Make a directory /tmp/test, add to it a file named "a" and a
>>    directory named "test", and add to /tmp/test/test a file named "b".
>> 3. Type `M-x copy-directory RET /tmp/test RET ~ RET' to copy /tmp/test
>>    recursively to ~.
>> 4. Type `C-x d' and at the prompt `~' to visit ~ in Dired, put the
>>    cursor on the directory "test" and type `i' to open "test" as a
>>    subdirectory.  This is the result:
>>
>>   /home/steve/test:
>>   total used in directory 16 available 7794948
>>   -rw-r--r--  1 steve users    4 2010-01-08 23:57 a
>>   -rw-r--r--  1 steve users    7 2010-01-08 23:57 b

Should be fixed now. However, the patch is a little bit different from
yours.

> This is due to the following code in copy-directory:
>
>     (if (and (file-directory-p newname)
>              (not (string-equal (file-name-nondirectory directory)
>     				(file-name-nondirectory newname))))
> 	(setq newname
> 	      (expand-file-name (file-name-nondirectory directory) newname)))
>
> Specifically, the equality check prevents newname from being changed
> from "home/steve/test" to "home/steve/test/test".  Removing this check,
> as in the below patch, fixes the above breakage.  I don't see any real
> problem this check prevents, but maybe I'm overlooking something.

IIRC, there were some problems when copying a directory into an existing
one. Cannot remember the exact test case, because I haven't written a
comment about.

> Steve Berman

Best regards, Michael.




Reply sent to Michael Albinus <michael.albinus <at> gmx.de>:
You have taken responsibility. (Wed, 13 Jan 2010 10:56:02 GMT) Full text and rfc822 format available.

Notification sent to Stephen Berman <stephen.berman <at> gmx.net>:
bug acknowledged by developer. (Wed, 13 Jan 2010 10:56:02 GMT) Full text and rfc822 format available.

Message #19 received at 5343-done <at> debbugs.gnu.org (full text, mbox):

From: Michael Albinus <michael.albinus <at> gmx.de>
To: Stephen Berman <stephen.berman <at> gmx.net>
Cc: 5343-done <at> debbugs.gnu.org
Subject: Re: bug#5343: 23.1.91; recursive directory copying is broken
Date: Wed, 13 Jan 2010 11:55:54 +0100
Stephen Berman <stephen.berman <at> gmx.net> writes:

> I confirm it's fixed.  Thanks!

Closing bug in debbugs.

> Steve Berman

Best regards, Michael.




Information forwarded to owner <at> debbugs.gnu.org, bug-gnu-emacs <at> gnu.org:
bug#5343; Package emacs. (Wed, 13 Jan 2010 11:32:02 GMT) Full text and rfc822 format available.

Message #22 received at 5343 <at> debbugs.gnu.org (full text, mbox):

From: Stephen Berman <stephen.berman <at> gmx.net>
To: Michael Albinus <michael.albinus <at> gmx.de>
Cc: 5343 <at> debbugs.gnu.org
Subject: Re: bug#5343: 23.1.91; recursive directory copying is broken
Date: Wed, 13 Jan 2010 11:52:20 +0100
On Tue, 12 Jan 2010 23:07:31 +0100 Michael Albinus <michael.albinus <at> gmx.de> wrote:

> Stephen Berman <stephen.berman <at> gmx.net> writes:
>
>>> 1. emacs -Q
>>> 2. Make a directory /tmp/test, add to it a file named "a" and a
>>>    directory named "test", and add to /tmp/test/test a file named "b".
>>> 3. Type `M-x copy-directory RET /tmp/test RET ~ RET' to copy /tmp/test
>>>    recursively to ~.
>>> 4. Type `C-x d' and at the prompt `~' to visit ~ in Dired, put the
>>>    cursor on the directory "test" and type `i' to open "test" as a
>>>    subdirectory.  This is the result:
>>>
>>>   /home/steve/test:
>>>   total used in directory 16 available 7794948
>>>   -rw-r--r--  1 steve users    4 2010-01-08 23:57 a
>>>   -rw-r--r--  1 steve users    7 2010-01-08 23:57 b
>
> Should be fixed now.

I confirm it's fixed.  Thanks!

Steve Berman




bug archived. Request was from Debbugs Internal Request <bug-gnu-emacs <at> gnu.org> to internal_control <at> debbugs.gnu.org. (Wed, 10 Feb 2010 12:24:03 GMT) Full text and rfc822 format available.

This bug report was last modified 15 years and 129 days ago.

Previous Next


GNU bug tracking system
Copyright (C) 1999 Darren O. Benham, 1997,2003 nCipher Corporation Ltd, 1994-97 Ian Jackson.