Subject: Re: bug#69606: [PATCH] Ensure default-directory exists when generating diff

From: Michael Albinus <[email-masked]>
Date: Thu, 07 Mar 2024 11:19:10 +0100

Philip Kaludercic <[email-masked]> writes:

Hi Philip,

> diff --git a/lisp/vc/diff.el b/lisp/vc/diff.el
> index a64fbc47853..47566dbc40b 100644
> --- a/lisp/vc/diff.el
> +++ b/lisp/vc/diff.el
> @@ -188,7 +188,9 @@ diff-no-select
>                                    (list (or old-alt old)
>                                          (or new-alt new)))))
>  		     " "))
> -	 (thisdir default-directory))
> +	 (thisdir (if (file-exists-p default-directory)
> +                      default-directory
> +                    (expand-file-name "~"))))
>      (with-current-buffer buf
>        (setq buffer-read-only t)
>        (buffer-disable-undo (current-buffer))

I would use temporary-file-directory (or even
small-temporary-file-directory). Spamming the home directory with
(temporary) diff files doesn't sound like a good idea.

> Any other ideas?  Perhaps we should always set the default directory to
> that

Perhaps, but I don't know whether there are undesired side effects, for
example when using relative file names. OTOH, if default-directory is
remote or unwritable, we might have problems anyway.

Best regards, Michael.