* files.el (copy-directory): Set directory attributes only in case
authorMichael Albinus <michael.albinus@gmx.de>
Thu, 22 Sep 2011 10:00:07 +0000 (12:00 +0200)
committerMichael Albinus <michael.albinus@gmx.de>
Thu, 22 Sep 2011 10:00:07 +0000 (12:00 +0200)
they could be retrieved from the source directory.  (Bug#9565)

lisp/ChangeLog
lisp/files.el

index 17000ca..013df43 100644 (file)
@@ -1,3 +1,8 @@
+2011-09-22  Michael Albinus  <michael.albinus@gmx.de>
+
+       * files.el (copy-directory): Set directory attributes only in case
+       they could be retrieved from the source directory.  (Bug#9565)
+
 2011-09-22  Dima Kogan  <dkogan@secretsauce.net>  (tiny change)
 
        * progmodes/hideshow.el (hs-looking-at-block-start-p)
index b29c059..8b05b62 100644 (file)
@@ -4941,9 +4941,10 @@ directly into NEWNAME instead."
              (copy-file file target t keep-time)))))
 
       ;; Set directory attributes.
-      (set-file-modes newname (file-modes directory))
-      (if keep-time
-         (set-file-times newname (nth 5 (file-attributes directory)))))))
+      (let ((modes (file-modes directory))
+           (times (and keep-time (nth 5 (file-attributes directory)))))
+       (if modes (set-file-modes newname modes))
+       (if times (set-file-times newname times))))))
 \f
 (put 'revert-buffer-function 'permanent-local t)
 (defvar revert-buffer-function nil