aboutsummaryrefslogtreecommitdiff
path: root/lisp/magit-bisect.el
diff options
context:
space:
mode:
authorJonas Bernoulli <jonas@bernoul.li>2023-03-17 18:51:10 +0100
committerJonas Bernoulli <jonas@bernoul.li>2023-03-17 18:51:10 +0100
commitff4710afa6e92fd3e22bbc6163153a5fd1019337 (patch)
tree37af35cdcea10a88f597fc68358af3a58d66ac96 /lisp/magit-bisect.el
parent860648857875ca904c4b7b4678f7b8692296bb24 (diff)
Deprecate magit-git-dir to avoid needlessly repeating work
Five years ago in [1: 5f407a29ac] we took the first step toward this. 1: 2018-10-15 5f407a29ac63b338c3c75e30b4633b44d5745036 magit-gitdir: New function Previously we cached the wrong thing. `expand-file-name' is cheap but "git rev-parse --git-dir" is not. Because `magit-git-dir' is where we cached, rev-parse was still needlessly called multiple times with the same arguments during a refresh. The effect should be most noticeable during a rebase.
Diffstat (limited to 'lisp/magit-bisect.el')
-rw-r--r--lisp/magit-bisect.el15
1 files changed, 9 insertions, 6 deletions
diff --git a/lisp/magit-bisect.el b/lisp/magit-bisect.el
index 84d5995..fd93271 100644
--- a/lisp/magit-bisect.el
+++ b/lisp/magit-bisect.el
@@ -134,7 +134,8 @@ other actions from the bisect transient command (\
(interactive)
(magit-confirm 'reset-bisect)
(magit-run-git "bisect" "reset")
- (ignore-errors (delete-file (magit-git-dir "BISECT_CMD_OUTPUT"))))
+ (ignore-errors
+ (delete-file (expand-file-name "BISECT_CMD_OUTPUT" (magit-gitdir)))))
;;;###autoload
(defun magit-bisect-good ()
@@ -197,7 +198,7 @@ bisect run'."
;; next `git bisect run' call requires the bisect to be started.
(magit-with-toplevel
(magit-process-git
- (list :file (magit-git-dir "BISECT_CMD_OUTPUT"))
+ (list :file (expand-file-name "BISECT_CMD_OUTPUT" (magit-gitdir)))
(magit-process-git-arguments
(list "bisect" "start" bad good args)))
(magit-refresh)))
@@ -225,7 +226,8 @@ bisect run'."
(output (buffer-substring-no-properties
(oref section content)
(oref section end))))
- (with-temp-file (magit-git-dir "BISECT_CMD_OUTPUT")
+ (with-temp-file
+ (expand-file-name "BISECT_CMD_OUTPUT" (magit-gitdir))
(insert output)))))
(magit-refresh))
(message "Bisecting...done")))))
@@ -233,16 +235,17 @@ bisect run'."
;;; Sections
(defun magit-bisect-in-progress-p ()
- (file-exists-p (magit-git-dir "BISECT_LOG")))
+ (file-exists-p (expand-file-name "BISECT_LOG" (magit-gitdir))))
(defun magit-bisect-terms ()
- (magit-file-lines (magit-git-dir "BISECT_TERMS")))
+ (magit-file-lines (expand-file-name "BISECT_TERMS" (magit-gitdir))))
(defun magit-insert-bisect-output ()
"While bisecting, insert section with output from `git bisect'."
(when (magit-bisect-in-progress-p)
(let* ((lines
- (or (magit-file-lines (magit-git-dir "BISECT_CMD_OUTPUT"))
+ (or (magit-file-lines
+ (expand-file-name "BISECT_CMD_OUTPUT" (magit-gitdir)))
(list "Bisecting: (no saved bisect output)"
"It appears you have invoked `git bisect' from a shell."
"There is nothing wrong with that, we just cannot display"