Subject: bug#10489: 24.0.92; dired-do-copy may create infinite directory hierarchy

From: Eli Zaretskii <[email-masked]>
Date: Fri, 24 Feb 2012 22:04:08 +0200

> From: Thierry Volpiatto <[email-masked]>
> Cc: Eli Zaretskii <[email-masked]>,  [email-masked]
> Date: Fri, 24 Feb 2012 17:02:16 +0100
> 
> (defun files-equal-p (file1 file2)
>   "Return non-nil if FILE1 and FILE2 name the same file."
>   (let ((handler (or (find-file-name-handler file1 'files-equal-p)
>                      (find-file-name-handler file2 'files-equal-p))))
>     (if handler
>         (funcall handler 'files-equal-p file1 file2)

If FILE1 and FILE2 have different 'files-equal-p handlers, which one
of them, if any, should be invoked here?

IOW, shouldn't we invoke a file handler only if it can handle _both_
files?  Also, if each file has a different handler, doesn't that in
itself already mean the files are not equal?

> (defun file-subdir-of-p (dir1 dir2)
>   "Return non-nil if DIR1 is a subdirectory of DIR2.
> Note that a directory is treated by this function as a subdirectory of itself.
> This function only works when its two arguments already exist,
> when they don't, it returns nil."
>   (let ((handler (or (find-file-name-handler dir1 'file-subdir-of-p)
>                      (find-file-name-handler dir2 'file-subdir-of-p))))
>     (if handler
>         (funcalll handler 'file-subdir-of-p dir1 dir2)

Same issue here.  Except that, unlike in the files-equal-p case, it's
not so clear what to do if each file has a different handler, or if
one has a handler, but the other doesn't.