Subject: Re: bug#58503: 29.0.50; eshell, with remote pwd, diff between folders doesn't create a *Diff* buffer

From: Michael Albinus <[email-masked]>
Date: Tue, 15 Nov 2022 21:09:58 +0100

[email-masked] writes:

Hi,

> M-x eshell
> cd into a remote directory, for example 'cd /sudo::~/'
> compare two existing folders with 'diff a/ b/' or 'diff -r a/ b/'
>
> Eshell prints diff output into the *eshell* buffer instead of displaying
> a *Diff* buffer. This isn't an issue in a local pwd.

I fear we cannot do too much about.

"diff" in eshell calls `eshell/diff'. This calls `diff-no-select', and
this calls `diff-file-local-copy', which is in reality
`file-local-copy'. The argument of the latter is the directory "a/" (or
"b/").

`file-local-copy' is not specified for directories, just for files. So
it fails, and the error is caught in `eshell/diff'. Due to the error,
eshell replaces "diff" by "*diff", the external command, and we see the
output in the eshell buffer.

In the local case, `file-local-copy' returns nil, and `diff-no-select'
continues to work. And also the remote case works as expected, if we try
to compare two files, and not directories, because `file-local-copy'
knows what to do.

A fix would require to replace `file-local-copy' by something else in
`diff-no-select'. Wouldn't be trivial, I fear.

Another approach would be to extend `file-local-copy' to support also
directories. Also not trivial, and I don't know whether we want this.

Best regards, Michael.