all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
From: Philip Kaludercic <philipk@posteo.net>
To: Michael Albinus <michael.albinus@gmx.de>
Cc: 69606@debbugs.gnu.org
Subject: bug#69606: [PATCH] Ensure default-directory exists when generating diff
Date: Fri, 08 Mar 2024 07:47:29 +0000	[thread overview]
Message-ID: <87sf115fn2.fsf@posteo.net> (raw)
In-Reply-To: <87bk7q2vkx.fsf@gmx.de> (Michael Albinus's message of "Thu, 07 Mar 2024 11:19:10 +0100")

Michael Albinus <michael.albinus@gmx.de> writes:

> Philip Kaludercic <philipk@posteo.net> 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.

If I am not mistaken, the command does not create any files, the output
of diff is written directly into the *diff* buffer.

>> 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.

I don't quite understand how, but it seems that some specific sequence
of commands can start diff in a directory I just deleted, without this
being necessary.  The reason I was thinking about a more general
solution, is that something like

--8<---------------cut here---------------start------------->8---
(let ((default-directory "/this/does/not/exists"))
  (make-process :command '("true")))
--8<---------------cut here---------------end--------------->8---

will always fail, even though "true" doesn't use the current working
directory.  I think it would be useful to have some :fallback option for
these situations, to ensure that if `default-directory' doesn't exist,
any other directory should be used instead.

> Best regards, Michael.

-- 
	Philip Kaludercic on peregrine





  reply	other threads:[~2024-03-08  7:47 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-03-07  9:27 bug#69606: [PATCH] Ensure default-directory exists when generating diff Philip Kaludercic
2024-03-07 10:19 ` Michael Albinus via Bug reports for GNU Emacs, the Swiss army knife of text editors
2024-03-08  7:47   ` Philip Kaludercic [this message]
2024-03-09 16:45     ` Michael Albinus via Bug reports for GNU Emacs, the Swiss army knife of text editors

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=87sf115fn2.fsf@posteo.net \
    --to=philipk@posteo.net \
    --cc=69606@debbugs.gnu.org \
    --cc=michael.albinus@gmx.de \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this external index

	https://git.savannah.gnu.org/cgit/emacs.git
	https://git.savannah.gnu.org/cgit/emacs/org-mode.git

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.