GNU bug report logs - #69606
[PATCH] Ensure default-directory exists when generating diff

Previous Next

Package: emacs;

Reported by: Philip Kaludercic <philipk <at> posteo.net>

Date: Thu, 7 Mar 2024 09:29:01 UTC

Severity: normal

Tags: patch

Fixed in version 31.1

Done: Michael Albinus <michael.albinus <at> gmx.de>

Bug is archived. No further changes may be made.

Full log


Message #38 received at 69606 <at> debbugs.gnu.org (full text, mbox):

From: Philip Kaludercic <philipk <at> posteo.net>
To: Michael Albinus <michael.albinus <at> gmx.de>
Cc: Stefan Kangas <stefankangas <at> gmail.com>, 69606 <at> debbugs.gnu.org
Subject: Re: bug#69606: [PATCH] Ensure default-directory exists when
 generating diff
Date: Mon, 17 Feb 2025 21:00:35 +0000
Michael Albinus <michael.albinus <at> gmx.de> writes:

> Philip Kaludercic <philipk <at> posteo.net> writes:
>
> Hi Philipp,
>
>>> I don't understand why you can't use temporary-file-directory. Did I
>>> miss this point in the discussion?
>>
>> No, you are absolutely right, that is the better idea!
>
> Thanks. However, why not do it more simple, like appended?

Is it safe to always use a temporary directory?  I would have expected
there to be edge-cases when using TRAMP where that might matter, and we
should only fall back if really necessary?

> Best regards, Michael.
>
> diff --git a/lisp/vc/diff.el b/lisp/vc/diff.el
> index 70497a97d56..875deb68724 100644
> --- a/lisp/vc/diff.el
> +++ b/lisp/vc/diff.el
> @@ -187,8 +187,7 @@ diff-no-select
>  					       (prin1-to-string new))))
>                                    (list (or old-alt old)
>                                          (or new-alt new)))))
> -		     " "))
> -	 (thisdir default-directory))
> +		     " ")))
>      (with-current-buffer buf
>        (setq buffer-read-only t)
>        (buffer-disable-undo (current-buffer))
> @@ -199,25 +198,26 @@ diff-no-select
>        (setq-local revert-buffer-function
>                    (lambda (_ignore-auto _noconfirm)
>                      (diff-no-select old new switches no-async (current-buffer))))
> -      (setq default-directory thisdir)
> +      (setq default-directory temporary-file-directory)
>        (setq diff-default-directory default-directory)
>        (let ((inhibit-read-only t))
>  	(insert command "\n"))
> -      (if (and (not no-async) (fboundp 'make-process))
> -	  (let ((proc (start-process "Diff" buf shell-file-name
> -                                     shell-command-switch command)))
> -	    (set-process-filter proc #'diff-process-filter)
> -            (set-process-sentinel
> -             proc (lambda (proc _msg)
> -                    (with-current-buffer (process-buffer proc)
> -                      (diff-sentinel (process-exit-status proc)
> -                                     old-alt new-alt)))))
> -	;; Async processes aren't available.
> -	(let ((inhibit-read-only t))
> -	  (diff-sentinel
> -	   (call-process shell-file-name nil buf nil
> -			 shell-command-switch command)
> -           old-alt new-alt))))
> +      (with-file-modes #o600
> +        (if (and (not no-async) (fboundp 'make-process))
> +	    (let ((proc (start-process "Diff" buf shell-file-name
> +                                       shell-command-switch command)))
> +	      (set-process-filter proc #'diff-process-filter)
> +              (set-process-sentinel
> +               proc (lambda (proc _msg)
> +                      (with-current-buffer (process-buffer proc)
> +                        (diff-sentinel (process-exit-status proc)
> +                                       old-alt new-alt)))))
> +	  ;; Async processes aren't available.
> +	  (let ((inhibit-read-only t))
> +	    (diff-sentinel
> +	     (call-process shell-file-name nil buf nil
> +			   shell-command-switch command)
> +             old-alt new-alt)))))
>      buf))
>
>  (defun diff-process-filter (proc string)




This bug report was last modified 85 days ago.

Previous Next


GNU bug tracking system
Copyright (C) 1999 Darren O. Benham, 1997,2003 nCipher Corporation Ltd, 1994-97 Ian Jackson.