emacs-elpa-diffs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[nongnu] elpa/why-this 357cfa7e1e 34/59: Ensure that temporary file crea


From: ELPA Syncer
Subject: [nongnu] elpa/why-this 357cfa7e1e 34/59: Ensure that temporary file created by Git backend is deleted
Date: Sun, 27 Nov 2022 16:02:51 -0500 (EST)

branch: elpa/why-this
commit 357cfa7e1e462e4d0ad651b527487c5f5b1c0de3
Author: Akib Azmain Turja <akib@disroot.org>
Commit: Akib Azmain Turja <akib@disroot.org>

    Ensure that temporary file created by Git backend is deleted
---
 why-this.el | 27 +++++++++++++++------------
 1 file changed, 15 insertions(+), 12 deletions(-)

diff --git a/why-this.el b/why-this.el
index f17bd9019a..104b4cec1b 100644
--- a/why-this.el
+++ b/why-this.el
@@ -703,17 +703,21 @@ Do CMD with ARGS."
                              "git rev-parse --is-inside-work-tree"))))
     ('line-data
      (when (> (- (nth 1 args) (nth 0 args)) 0)
-       (let* ((temp-file (let ((file (make-temp-file "why-this-git-"))
-                               (text (buffer-substring-no-properties
-                                      (point-min) (point-max))))
-                           (with-temp-file file
-                             (insert text))
-                           file))
-              (command (format (concat
-                                "git blame -L %i,%i \"%s\" --porcelain"
-                                " --contents \"%s\" ; echo $?")
-                               (nth 0 args) (1- (nth 1 args))
-                               (buffer-file-name) temp-file))
+       (let* ((command (let ((temp-file
+                              (let ((file (make-temp-file "why-this-git-"))
+                                    (text (buffer-substring-no-properties
+                                           (point-min) (point-max))))
+                                (with-temp-file file
+                                  (insert text))
+                                file)))
+                         (unwind-protect
+                             (format (concat
+                                      "git blame -L %i,%i \"%s\""
+                                      " --porcelain --contents \"%s\""
+                                      " ; echo $?")
+                                     (nth 0 args) (1- (nth 1 args))
+                                     (buffer-file-name) temp-file)
+                           (delete-file temp-file))))
               (blame (butlast
                       (split-string (shell-command-to-string command)
                        "\n")))
@@ -732,7 +736,6 @@ Do CMD with ARGS."
                                  :author why-this--git-author-name
                                  :time (current-time)
                                  :desc "Uncommitted changes")))))))
-         (delete-file temp-file)
          (setq blame (butlast blame))
          (when (zerop status)
            (let (commit-alist)



reply via email to

[Prev in Thread] Current Thread [Next in Thread]