Subject: 28.2; Copying files in dired

From: Skyler Mayfield <[email-masked]>
Date: Mon, 31 Oct 2022 08:25:27 +0100

I've discovered what seems might be a bug in the functions 
dired-do-copy
and dired-do-rename. Copying or renaming files fails when 
attempting to
merge directories. Consider the following:

1. Start emacs via emacs -Q
2. Navigate with dired to some safe, user-writable directory, such 
as
your home directory.
3. Create two directories called testA and testB, with
dired-create-directory for instance.
4. Inside ~/testA create another subdirectory called
foo.
5. Create a file ~/testA/foo/bar and enter
some example text.
6. In a dired buffer visiting ~/testA, mark the foo directory.
7. Copy the directory to the other directory, via dired-do-copy. 
This
should prompt for a destination, ~/testA/ by default, so press 
backspace
twice and complete the destination to ~/testB/ and press enter.
8. Now modify the file ~/testB/foo/bar and save it. (This step is
actually optional as the outcome won't change either way.)
9. Switch back to the dired buffer visiting ~/testA/ and attempt 
to copy
the foo directory to ~/testB/ again as in step 7.
10. You will be prompted to overwrite, press y or ! here to do so. 
Now
you should be prompted to copy recursively, so type in yes and 
press
enter.
11. The command fails with the error: Copy: 
'/home/clock/testA/foo' to '/home/clock/testB/' failed:
(file-already-exists File exists /home/clock/testB/foo)

My expectation here is that dired would recurse into the foo 
directory,
and in the case that you have pressed y, it should ask if you 
would like
to overwrite the file bar, and if you have pressed !, you 
shouldn't be
prompted and the file should be overwritten. Furthermore, if the
contents of ~/testA/foo differ further, with more subdirectories 
and
files, those files should all be copied over as with the behavior 
of cp
-r in bash. If you perform these same steps up to step 9, but in 
 step 9
you use dired-do-rename, the resulting error changes to this: 
Move: '/home/clock/testA/foo' to '/home/clock/testB/foo' failed:
(file-error Renaming Directory not empty /home/clock/testA/foo 
/home/clock/testB/foo)

In GNU Emacs 28.2 (build 2, x86_64-unknown-linux-gnu, GTK+ Version 
3.24.34, cairo version 1.16.0)
 of 2022-09-13 built on a-fsn-de
Windowing system distributor 'The X.Org Foundation', version 
11.0.12101004
System Description: Void Linux

Configured using:
 'configure --with-x-toolkit=gtk3 --with-xwidgets --prefix=/usr
 --sysconfdir=/etc --sbindir=/usr/bin --bindir=/usr/bin
 --mandir=/usr/share/man --infodir=/usr/share/info 
 --localstatedir=/var
 --host=x86_64-unknown-linux-gnu --build=x86_64-unknown-linux-gnu
 '--libdir=${exec_prefix}/lib64' --with-file-notification=inotify
 --with-modules --with-jpeg --with-tiff --with-gif --with-png 
 --with-xpm
 --with-rsvg --without-imagemagick --with-xml2 --with-gnutls
 --with-sound --with-m17n-flt --with-json --with-harfbuzz 
 --with-cairo
 --with-libgmp --with-native-compilation 'CFLAGS=-fno-PIE 
 -mtune=generic
 -O2 -pipe -g -fdebug-prefix-map=/builddir/emacs-28.2=.' 
 'CPPFLAGS= '
 'LDFLAGS=-no-pie -Wl,--as-needed ''

Configured features:
ACL CAIRO DBUS FREETYPE GIF GLIB GMP GNUTLS GSETTINGS HARFBUZZ 
JPEG JSON
LCMS2 LIBOTF LIBXML2 M17N_FLT MODULES NATIVE_COMP NOTIFY INOTIFY 
PDUMPER
PNG RSVG SECCOMP SOUND THREADS TIFF TOOLKIT_SCROLL_BARS X11 XDBE 
XIM XPM
XWIDGETS GTK3 ZLIB

Important settings:
  value of $LC_COLLATE: C
  value of $LANG: en_US.UTF-8
  locale-coding-system: utf-8-unix

Major mode: Lisp Interaction

Minor modes in effect:
  tooltip-mode: t
  global-eldoc-mode: t
  eldoc-mode: t
  show-paren-mode: t
  electric-indent-mode: t
  mouse-wheel-mode: t
  tool-bar-mode: t
  menu-bar-mode: t
  file-name-shadow-mode: t
  global-font-lock-mode: t
  font-lock-mode: t
  blink-cursor-mode: t
  auto-composition-mode: t
  auto-encryption-mode: t
  auto-compression-mode: t
  line-number-mode: t
  indent-tabs-mode: t
  transient-mark-mode: t

Load-path shadows:
None found.

Features:
(shadow sort mail-extr emacsbug message rmc puny dired 
dired-loaddefs
rfc822 mml mml-sec epa derived epg rfc6068 epg-config gnus-util 
rmail
rmail-loaddefs auth-source eieio eieio-core eieio-loaddefs
password-cache json map text-property-search mm-decode mm-bodies
mm-encode mail-parse rfc2231 mailabbrev gmm-utils mailheader 
sendmail
rfc2047 rfc2045 ietf-drums mm-util mail-prsvr mail-utils apropos 
comp
comp-cstr warnings rx cl-seq cl-macs cl-extra help-mode seq 
byte-opt gv
bytecomp byte-compile cconv time-date subr-x cl-loaddefs cl-lib
iso-transl tooltip eldoc paren electric uniquify ediff-hook 
vc-hooks
lisp-float-type elisp-mode mwheel term/x-win x-win term/common-win 
x-dnd
tool-bar dnd fontset image regexp-opt fringe tabulated-list 
replace
newcomment text-mode lisp-mode prog-mode register page tab-bar 
menu-bar
rfn-eshadow isearch easymenu timer select scroll-bar mouse 
jit-lock
font-lock syntax font-core term/tty-colors frame minibuffer 
cl-generic
cham georgian utf-8-lang misc-lang vietnamese tibetan thai 
tai-viet lao
korean japanese eucjp-ms cp51932 hebrew greek romanian slovak 
czech
european ethiopic indian cyrillic chinese composite emoji-zwj 
charscript
charprop case-table epa-hook jka-cmpr-hook help simple abbrev 
obarray
cl-preloaded nadvice button loaddefs faces cus-face macroexp files
window text-properties overlay sha1 md5 base64 format env 
code-pages
mule custom widget hashtable-print-readable backquote threads
xwidget-internal dbusbind inotify lcms2 dynamic-setting
system-font-setting font-render-setting cairo move-toolbar gtk 
x-toolkit
x multi-tty make-network-process native-compile emacs)

Memory information:
((conses 16 89023 9463)
 (symbols 48 7940 1)
 (strings 32 23961 4125)
 (string-bytes 1 841821)
 (vectors 16 18290)
 (vector-slots 8 337377 23668)
 (floats 8 32 33)
 (intervals 56 307 0)
 (buffers 992 13))