]> git.eshelyaron.com Git - emacs.git/commitdiff
Use a persistent directory as default directory in diff
authorMichael Albinus <michael.albinus@gmx.de>
Fri, 21 Feb 2025 13:47:15 +0000 (14:47 +0100)
committerEshel Yaron <me@eshelyaron.com>
Sun, 23 Feb 2025 08:07:49 +0000 (09:07 +0100)
* lisp/vc/diff.el (diff-no-select): Use `temporary-file-directory'
as default directory.  Set default file permissions temporarily to
#o600.  (Bug#69606)

(cherry picked from commit ae439cc1b9f428a8247548f4ef3b992608a3c09b)

lisp/vc/diff.el

index 57146420b2a6cf1db9ee7dbd54fba491ff383227..9987e303e25b423d7e1d38c87e8e36c14b89ace6 100644 (file)
@@ -188,8 +188,7 @@ returns the buffer used."
                                               (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))
@@ -200,25 +199,26 @@ returns the buffer used."
       (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)