[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[nongnu] elpa/git-commit ff4710afa6 3/7: Deprecate magit-git-dir to avoi
From: |
ELPA Syncer |
Subject: |
[nongnu] elpa/git-commit ff4710afa6 3/7: Deprecate magit-git-dir to avoid needlessly repeating work |
Date: |
Fri, 17 Mar 2023 19:59:48 -0400 (EDT) |
branch: elpa/git-commit
commit ff4710afa6e92fd3e22bbc6163153a5fd1019337
Author: Jonas Bernoulli <jonas@bernoul.li>
Commit: Jonas Bernoulli <jonas@bernoul.li>
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.
---
lisp/git-rebase.el | 3 +-
lisp/magit-bisect.el | 15 +++--
lisp/magit-branch.el | 5 +-
lisp/magit-commit.el | 8 ++-
lisp/magit-ediff.el | 6 +-
lisp/magit-files.el | 9 +--
lisp/magit-git.el | 45 +++++++--------
lisp/magit-gitignore.el | 2 +-
lisp/magit-merge.el | 10 ++--
lisp/magit-notes.el | 2 +-
lisp/magit-sequence.el | 145 +++++++++++++++++++++++++++---------------------
lisp/magit-submodule.el | 12 ++--
12 files changed, 149 insertions(+), 113 deletions(-)
diff --git a/lisp/git-rebase.el b/lisp/git-rebase.el
index 793a6c2f0d..b3a219d70b 100644
--- a/lisp/git-rebase.el
+++ b/lisp/git-rebase.el
@@ -734,7 +734,8 @@ running \"man git-rebase\" at the command line) for
details."
(magit-confirm 'abort-rebase "Abort this rebase" nil 'noabort)))
(defun git-rebase-autostash-save ()
- (--when-let (magit-file-line (magit-git-dir "rebase-merge/autostash"))
+ (--when-let (magit-file-line
+ (expand-file-name "rebase-merge/autostash" (magit-gitdir)))
(push (cons 'stash it) with-editor-cancel-alist)))
(defun git-rebase-autostash-apply ()
diff --git a/lisp/magit-bisect.el b/lisp/magit-bisect.el
index 84d5995320..fd93271a0b 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"
diff --git a/lisp/magit-branch.el b/lisp/magit-branch.el
index 3e80201e2b..85e7c876fc 100644
--- a/lisp/magit-branch.el
+++ b/lisp/magit-branch.el
@@ -794,8 +794,9 @@ and also rename the respective reflog file."
(magit-run-git "update-ref" "-d" old)))
(defun magit--rename-reflog-file (old new)
- (let ((old (magit-git-dir (concat "logs/" old)))
- (new (magit-git-dir (concat "logs/" new))))
+ (let* ((dir (magit-gitdir))
+ (old (expand-file-name (concat "logs/" old) dir))
+ (new (expand-file-name (concat "logs/" new) dir)))
(when (file-exists-p old)
(make-directory (file-name-directory new) t)
(rename-file old new t))))
diff --git a/lisp/magit-commit.el b/lisp/magit-commit.el
index 247a177ac5..5dc514ece8 100644
--- a/lisp/magit-commit.el
+++ b/lisp/magit-commit.el
@@ -369,7 +369,7 @@ depending on the value of option
`magit-commit-squash-confirm'."
(setq this-command #'magit-rebase-continue)
(magit-run-git-sequencer "rebase" "--continue")
nil)
- ((and (file-exists-p (magit-git-dir "MERGE_MSG"))
+ ((and (file-exists-p (expand-file-name "MERGE_MSG" (magit-gitdir)))
(not (magit-anything-unstaged-p)))
(or args (list "--")))
((not (magit-anything-unstaged-p))
@@ -578,7 +578,8 @@ See `magit-commit-absorb' for an alternative
implementation."
;; requires a working tree.
(magit-with-toplevel
(magit-anything-unstaged-p)))
- (squash (let ((f (magit-git-dir "rebase-merge/rewritten-pending")))
+ (squash (let ((f (expand-file-name "rebase-merge/rewritten-pending"
+ (magit-gitdir))))
(and (file-exists-p f) (length (magit-file-lines f)))))
(noalt nil))
(pcase (list staged unstaged command)
@@ -610,7 +611,8 @@ See `magit-commit-absorb' for an alternative
implementation."
(equal arg (buffer-local-value 'magit-buffer-typearg
buf)))))))
((eq command 'magit-commit-amend)
(setq rev nil))
- ((or squash (file-exists-p (magit-git-dir "rebase-merge/amend")))
+ ((or squash
+ (file-exists-p (expand-file-name "rebase-merge/amend"
(magit-gitdir))))
(setq rev "HEAD^"))
(t
(message "No alternative diff while committing")
diff --git a/lisp/magit-ediff.el b/lisp/magit-ediff.el
index c3d0996574..a207ad1f92 100644
--- a/lisp/magit-ediff.el
+++ b/lisp/magit-ediff.el
@@ -221,9 +221,11 @@ See info node `(magit) Ediffing' for more information
about this
and alternative commands."
(interactive (list (magit-read-unmerged-file)))
(magit-with-toplevel
- (let* ((revA (or (magit-name-branch "HEAD")
+ (let* ((dir (magit-gitdir))
+ (revA (or (magit-name-branch "HEAD")
(magit-commit-p "HEAD")))
- (revB (cl-find-if (lambda (head) (file-exists-p (magit-git-dir
head)))
+ (revB (cl-find-if (lambda (head)
+ (file-exists-p (expand-file-name head dir)))
'("MERGE_HEAD" "CHERRY_PICK_HEAD"
"REVERT_HEAD")))
(revB (or (magit-name-branch revB)
(magit-commit-p revB)))
diff --git a/lisp/magit-files.el b/lisp/magit-files.el
index 6afdd42799..527fd3a903 100644
--- a/lisp/magit-files.el
+++ b/lisp/magit-files.el
@@ -203,7 +203,8 @@ is done using `magit-find-index-noselect'."
(unless (equal magit-buffer-refname "{index}")
(user-error "%s isn't visiting the index" file))
(if (y-or-n-p (format "Update index with contents of %s" (buffer-name)))
- (let ((index (make-temp-name (magit-git-dir "magit-update-index-")))
+ (let ((index (make-temp-name
+ (expand-file-name "magit-update-index-" (magit-gitdir))))
(buffer (current-buffer)))
(when magit-wip-before-change-mode
(magit-wip-commit-before-change (list file) " before un-/stage"))
@@ -243,7 +244,7 @@ This command is like `find-file', except that it temporarily
binds `default-directory' to the actual git directory, while
reading the FILENAME."
(interactive
- (let ((default-directory (magit-git-dir)))
+ (let ((default-directory (magit-gitdir)))
(find-file-read-args "Find file: "
(confirm-nonexistent-file-or-buffer))))
(find-file filename wildcards))
@@ -259,7 +260,7 @@ This command is like `find-file-other-window', except that
it
temporarily binds `default-directory' to the actual git
directory, while reading the FILENAME."
(interactive
- (let ((default-directory (magit-git-dir)))
+ (let ((default-directory (magit-gitdir)))
(find-file-read-args "Find file in other window: "
(confirm-nonexistent-file-or-buffer))))
(find-file-other-window filename wildcards))
@@ -275,7 +276,7 @@ This command is like `find-file-other-frame', except that it
temporarily binds `default-directory' to the actual git
directory, while reading the FILENAME."
(interactive
- (let ((default-directory (magit-git-dir)))
+ (let ((default-directory (magit-gitdir)))
(find-file-read-args "Find file in other frame: "
(confirm-nonexistent-file-or-buffer))))
(find-file-other-frame filename wildcards))
diff --git a/lisp/magit-git.el b/lisp/magit-git.el
index cc02242a80..aebac343b9 100644
--- a/lisp/magit-git.el
+++ b/lisp/magit-git.el
@@ -810,6 +810,14 @@ Also see `magit-git-config-p'."
`(when-let ((default-directory (magit--safe-default-directory ,file)))
,@body))
+(defun magit-git-dir (&optional path)
+ "Like (expand-file-name PATH (magit-gitdir)) or just (magit-gitdir)."
+ (declare (obsolete 'magit-gitdir "Magit 4.0.0"))
+ (and-let* ((dir (magit-gitdir)))
+ (if path
+ (expand-file-name (convert-standard-filename path) dir)
+ dir)))
+
(defun magit-gitdir (&optional directory)
"Return the absolute and resolved path of the .git directory.
@@ -818,29 +826,20 @@ Otherwise return the .git directory for DIRECTORY, or if
that is
nil, then for `default-directory' instead. If the directory is
not located inside a Git repository, then return nil."
(let ((default-directory (or directory default-directory)))
- (magit-git-dir)))
-
-(defun magit-git-dir (&optional path)
- "Return the absolute and resolved path of the .git directory.
-
-If the `GIT_DIR' environment variable is define then return that.
-Otherwise return the .git directory for `default-directory'. If
-the directory is not located inside a Git repository, then return
-nil."
- (magit--with-refresh-cache (list default-directory 'magit-git-dir path)
- (magit--with-safe-default-directory nil
- (and-let* ((dir (magit-rev-parse-safe "--git-dir"))
- (dir (file-name-as-directory (magit-expand-git-file-name
dir)))
- (dir (if (file-remote-p dir)
- dir
- (concat (file-remote-p default-directory) dir))))
- (if path (expand-file-name (convert-standard-filename path) dir)
dir)))))
+ (magit--with-refresh-cache (list default-directory 'magit-gitdir)
+ (magit--with-safe-default-directory nil
+ (and-let*
+ ((dir (magit-rev-parse-safe "--git-dir"))
+ (dir (file-name-as-directory (magit-expand-git-file-name dir))))
+ (if (file-remote-p dir)
+ dir
+ (concat (file-remote-p default-directory) dir)))))))
(defvar magit--separated-gitdirs nil)
(defun magit--record-separated-gitdir ()
(let ((topdir (magit-toplevel))
- (gitdir (magit-git-dir)))
+ (gitdir (magit-gitdir)))
;; Kludge: git-annex converts submodule gitdirs to symlinks. See #3599.
(when (file-symlink-p (directory-file-name gitdir))
(setq gitdir (file-truename gitdir)))
@@ -976,7 +975,7 @@ is non-nil, in which case return nil."
;; Below a repository directory that is not located below the
;; working directory "git rev-parse --is-inside-git-dir" prints
;; "false", which is wrong.
- (let ((gitdir (magit-git-dir)))
+ (let ((gitdir (magit-gitdir)))
(cond (gitdir (file-in-directory-p default-directory gitdir))
(noerror nil)
(t (signal 'magit-outside-git-repo default-directory))))))
@@ -2384,7 +2383,8 @@ and this option only controls what face is used.")
(let ((file (cl-gensym "file")))
`(let ((magit--refresh-cache nil)
(,file (magit-convert-filename-for-git
- (make-temp-name (magit-git-dir "index.magit.")))))
+ (make-temp-name
+ (expand-file-name "index.magit." (magit-gitdir))))))
(unwind-protect
(magit-with-toplevel
(--when-let ,tree
@@ -2424,7 +2424,8 @@ and this option only controls what face is used.")
(or (magit-rev-verify ref) "")))
;; `--create-reflog' didn't exist before v2.6.0
(let ((oldrev (magit-rev-verify ref))
- (logfile (magit-git-dir (concat "logs/" ref))))
+ (logfile (expand-file-name (concat "logs/" ref)
+ (magit-gitdir))))
(unless (file-exists-p logfile)
(when oldrev
(magit-git-success "update-ref" "-d" ref oldrev))
@@ -2685,7 +2686,7 @@ out. Only existing branches can be selected."
" starting at")
(nconc (list "HEAD")
(magit-list-refnames)
- (directory-files (magit-git-dir) nil "_HEAD\\'"))
+ (directory-files (magit-gitdir) nil "_HEAD\\'"))
nil nil nil 'magit-revision-history
(or default (magit--default-starting-point)))
(user-error "Nothing selected")))
diff --git a/lisp/magit-gitignore.el b/lisp/magit-gitignore.el
index ec89042484..5a47fbf8f3 100644
--- a/lisp/magit-gitignore.el
+++ b/lisp/magit-gitignore.el
@@ -84,7 +84,7 @@ Also stage the file."
"Add the Git ignore RULE to \"$GIT_DIR/info/exclude\".
Rules in that file only affects this clone of the repository."
(interactive (list (magit-gitignore-read-pattern)))
- (magit--gitignore rule (magit-git-dir "info/exclude"))
+ (magit--gitignore rule (expand-file-name "info/exclude" (magit-gitdir)))
(magit-refresh))
;;;###autoload
diff --git a/lisp/magit-merge.el b/lisp/magit-merge.el
index 374c2eb47a..8db99f1eac 100644
--- a/lisp/magit-merge.el
+++ b/lisp/magit-merge.el
@@ -232,7 +232,7 @@ then also remove the respective remote branch."
"Abort the current merge operation.
\n(git merge --abort)"
(interactive)
- (unless (file-exists-p (magit-git-dir "MERGE_HEAD"))
+ (unless (file-exists-p (expand-file-name "MERGE_HEAD" (magit-gitdir)))
(user-error "No merge in progress"))
(magit-confirm 'abort-merge)
(magit-run-git-async "merge" "--abort"))
@@ -266,12 +266,13 @@ then also remove the respective remote branch."
;;; Utilities
(defun magit-merge-in-progress-p ()
- (file-exists-p (magit-git-dir "MERGE_HEAD")))
+ (file-exists-p (expand-file-name "MERGE_HEAD" (magit-gitdir))))
(defun magit--merge-range (&optional head)
(unless head
(setq head (magit-get-shortname
- (car (magit-file-lines (magit-git-dir "MERGE_HEAD"))))))
+ (car (magit-file-lines
+ (expand-file-name "MERGE_HEAD" (magit-gitdir)))))))
(and head
(concat (magit-git-string "merge-base" "--octopus" "HEAD" head)
".." head)))
@@ -299,7 +300,8 @@ Display the heads that are being merged.
If no merge is in progress, do nothing."
(when (magit-merge-in-progress-p)
(let* ((heads (mapcar #'magit-get-shortname
- (magit-file-lines (magit-git-dir "MERGE_HEAD"))))
+ (magit-file-lines
+ (expand-file-name "MERGE_HEAD" (magit-gitdir)))))
(range (magit--merge-range (car heads))))
(magit-insert-section (unmerged range)
(magit-insert-heading
diff --git a/lisp/magit-notes.el b/lisp/magit-notes.el
index f2e326fb84..7e4771d6b5 100644
--- a/lisp/magit-notes.el
+++ b/lisp/magit-notes.el
@@ -61,7 +61,7 @@
("a" "Abort merge" magit-notes-merge-abort)])
(defun magit-notes-merging-p ()
- (let ((dir (magit-git-dir "NOTES_MERGE_WORKTREE")))
+ (let ((dir (expand-file-name "NOTES_MERGE_WORKTREE" (magit-gitdir))))
(and (file-directory-p dir)
(directory-files dir nil "^[^.]"))))
diff --git a/lisp/magit-sequence.el b/lisp/magit-sequence.el
index aa32b70a21..14520f8c5d 100644
--- a/lisp/magit-sequence.el
+++ b/lisp/magit-sequence.el
@@ -353,11 +353,13 @@ the process manually."
(defun magit-cherry-pick-in-progress-p ()
;; .git/sequencer/todo does not exist when there is only one commit left.
- (or (file-exists-p (magit-git-dir "CHERRY_PICK_HEAD"))
- ;; And CHERRY_PICK_HEAD does not exist when a conflict happens
- ;; while picking a series of commits with --no-commit.
- (when-let ((line (magit-file-line (magit-git-dir "sequencer/todo"))))
- (string-prefix-p "pick" line))))
+ (let ((dir (magit-gitdir)))
+ (or (file-exists-p (expand-file-name "CHERRY_PICK_HEAD" dir))
+ ;; And CHERRY_PICK_HEAD does not exist when a conflict happens
+ ;; while picking a series of commits with --no-commit.
+ (and-let* ((line (magit-file-line
+ (expand-file-name "sequencer/todo" dir))))
+ (string-prefix-p "pick" line)))))
;;; Revert
@@ -409,11 +411,13 @@ without prompting."
(defun magit-revert-in-progress-p ()
;; .git/sequencer/todo does not exist when there is only one commit left.
- (or (file-exists-p (magit-git-dir "REVERT_HEAD"))
- ;; And REVERT_HEAD does not exist when a conflict happens while
- ;; reverting a series of commits with --no-commit.
- (when-let ((line (magit-file-line (magit-git-dir "sequencer/todo"))))
- (string-prefix-p "revert" line))))
+ (let ((dir (magit-gitdir)))
+ (or (file-exists-p (expand-file-name "REVERT_HEAD" dir))
+ ;; And REVERT_HEAD does not exist when a conflict happens
+ ;; while reverting a series of commits with --no-commit.
+ (and-let* ((line (magit-file-line
+ (expand-file-name "sequencer/todo" dir))))
+ (string-prefix-p "revert" line)))))
;;; Patch
@@ -506,7 +510,7 @@ This discards all changes made since the sequence started."
(user-error "Not applying any patches")))
(defun magit-am-in-progress-p ()
- (file-exists-p (magit-git-dir "rebase-apply/applying")))
+ (file-exists-p (expand-file-name "rebase-apply/applying" (magit-gitdir))))
;;; Rebase
@@ -814,12 +818,14 @@ edit. With a prefix argument the old message is reused
as-is."
(if (magit-rebase-in-progress-p)
(if (magit-anything-unstaged-p t)
(user-error "Cannot continue rebase with unstaged changes")
- (when (and (magit-anything-staged-p)
- (file-exists-p (magit-git-dir "rebase-merge"))
- (not (member (magit-toplevel)
- magit--rebase-public-edit-confirmed)))
- (magit-commit-amend-assert
- (magit-file-line (magit-git-dir "rebase-merge/orig-head"))))
+ (let ((dir (magit-gitdir)))
+ (when (and (magit-anything-staged-p)
+ (file-exists-p (expand-file-name "rebase-merge" dir))
+ (not (member (magit-toplevel)
+ magit--rebase-public-edit-confirmed)))
+ (magit-commit-amend-assert
+ (magit-file-line
+ (expand-file-name "rebase-merge/orig-head" dir)))))
(if noedit
(with-environment-variables (("GIT_EDITOR" "true"))
(magit-run-git-async (magit--rebase-resume-command) "--continue")
@@ -856,20 +862,25 @@ edit. With a prefix argument the old message is reused
as-is."
(defun magit-rebase-in-progress-p ()
"Return t if a rebase is in progress."
- (or (file-exists-p (magit-git-dir "rebase-merge"))
- (file-exists-p (magit-git-dir "rebase-apply/onto"))))
+ (let ((dir (magit-gitdir)))
+ (or (file-exists-p (expand-file-name "rebase-merge" dir))
+ (file-exists-p (expand-file-name "rebase-apply/onto" dir)))))
(defun magit--rebase-resume-command ()
- (if (file-exists-p (magit-git-dir "rebase-recursive")) "rbr" "rebase"))
+ (if (file-exists-p (expand-file-name "rebase-recursive" (magit-gitdir)))
+ "rbr"
+ "rebase"))
(defun magit-rebase--get-state-lines (file)
(and (magit-rebase-in-progress-p)
- (magit-file-line
- (magit-git-dir
- (concat (if (file-directory-p (magit-git-dir "rebase-merge"))
- "rebase-merge/"
- "rebase-apply/")
- file)))))
+ (let ((dir (magit-gitdir)))
+ (magit-file-line
+ (expand-file-name
+ (concat (if (file-directory-p (expand-file-name "rebase-merge" dir))
+ "rebase-merge/"
+ "rebase-apply/")
+ file)
+ dir)))))
;;; Sections
@@ -878,24 +889,25 @@ edit. With a prefix argument the old message is reused
as-is."
If no such sequence is in progress, do nothing."
(let ((picking (magit-cherry-pick-in-progress-p)))
(when (or picking (magit-revert-in-progress-p))
- (magit-insert-section (sequence)
- (magit-insert-heading (if picking "Cherry Picking" "Reverting"))
- (when-let ((lines
- (cdr (magit-file-lines (magit-git-dir "sequencer/todo")))))
- (dolist (line (nreverse lines))
- (when (string-match
- "^\\(pick\\|revert\\) \\([^ ]+\\) \\(.*\\)$" line)
- (magit-bind-match-strings (cmd hash msg) line
- (magit-insert-section (commit hash)
- (insert (propertize cmd 'font-lock-face 'magit-sequence-pick)
- " " (propertize hash 'font-lock-face 'magit-hash)
- " " msg "\n"))))))
- (magit-sequence-insert-sequence
- (magit-file-line (magit-git-dir (if picking
- "CHERRY_PICK_HEAD"
- "REVERT_HEAD")))
- (magit-file-line (magit-git-dir "sequencer/head")))
- (insert "\n")))))
+ (let ((dir (magit-gitdir)))
+ (magit-insert-section (sequence)
+ (magit-insert-heading (if picking "Cherry Picking" "Reverting"))
+ (when-let ((lines (cdr (magit-file-lines
+ (expand-file-name "sequencer/todo" dir)))))
+ (dolist (line (nreverse lines))
+ (when (string-match
+ "^\\(pick\\|revert\\) \\([^ ]+\\) \\(.*\\)$" line)
+ (magit-bind-match-strings (cmd hash msg) line
+ (magit-insert-section (commit hash)
+ (insert (propertize cmd 'font-lock-face
'magit-sequence-pick)
+ " " (propertize hash 'font-lock-face 'magit-hash)
+ " " msg "\n"))))))
+ (magit-sequence-insert-sequence
+ (magit-file-line
+ (expand-file-name (if picking "CHERRY_PICK_HEAD" "REVERT_HEAD")
+ dir))
+ (magit-file-line (expand-file-name "sequencer/head" dir)))
+ (insert "\n"))))))
(defun magit-insert-am-sequence ()
"Insert section for the on-going patch applying sequence.
@@ -941,13 +953,15 @@ If no such sequence is in progress, do nothing."
"Insert section for the on-going rebase sequence.
If no such sequence is in progress, do nothing."
(when (magit-rebase-in-progress-p)
- (let* ((interactive (file-directory-p (magit-git-dir "rebase-merge")))
+ (let* ((gitdir (magit-gitdir))
+ (interactive
+ (file-directory-p (expand-file-name "rebase-merge" gitdir)))
(dir (if interactive "rebase-merge/" "rebase-apply/"))
(name (thread-first (concat dir "head-name")
- magit-git-dir
+ (expand-file-name gitdir)
magit-file-line))
(onto (thread-first (concat dir "onto")
- magit-git-dir
+ (expand-file-name gitdir)
magit-file-line))
(onto (or (magit-rev-name onto name)
(magit-rev-name onto "refs/heads/*") onto))
@@ -966,7 +980,8 @@ status buffer (i.e. the reverse of how they will be
applied)."
(let ((comment-start (or (magit-get "core.commentChar") "#"))
lines)
(with-temp-buffer
- (insert-file-contents (magit-git-dir "rebase-merge/git-rebase-todo"))
+ (insert-file-contents
+ (expand-file-name "rebase-merge/git-rebase-todo" (magit-gitdir)))
(while (not (eobp))
(let ((ln (git-rebase-current-line)))
(when (oref ln action-type)
@@ -993,28 +1008,34 @@ status buffer (i.e. the reverse of how they will be
applied)."
"\s"
(magit-format-rev-summary hash) "\n"))
(error "failed to parse merge message hash"))))))
- (magit-sequence-insert-sequence
- (magit-file-line (magit-git-dir "rebase-merge/stopped-sha"))
- onto
- (and-let* ((lines (magit-file-lines (magit-git-dir "rebase-merge/done"))))
- (cadr (split-string (car (last lines)))))))
+ (let ((dir (magit-gitdir)))
+ (magit-sequence-insert-sequence
+ (magit-file-line (expand-file-name "rebase-merge/stopped-sha" dir))
+ onto
+ (and-let* ((lines (magit-file-lines
+ (expand-file-name "rebase-merge/done" dir))))
+ (cadr (split-string (car (last lines))))))))
(defun magit-rebase-insert-apply-sequence (onto)
- (let ((rewritten
- (--map (car (split-string it))
- (magit-file-lines (magit-git-dir "rebase-apply/rewritten"))))
- (stop (magit-file-line (magit-git-dir
"rebase-apply/original-commit"))))
+ (let* ((dir (magit-gitdir))
+ (rewritten
+ (--map (car (split-string it))
+ (magit-file-lines
+ (expand-file-name "rebase-apply/rewritten" dir))))
+ (stop (magit-file-line
+ (expand-file-name "rebase-apply/original-commit" dir))))
(dolist (patch (nreverse (cdr (magit-rebase-patches))))
(let ((hash (cadr (split-string (magit-file-line patch)))))
(unless (or (member hash rewritten)
(equal hash stop))
- (magit-sequence-insert-commit "pick" hash 'magit-sequence-pick)))))
- (magit-sequence-insert-sequence
- (magit-file-line (magit-git-dir "rebase-apply/original-commit"))
- onto))
+ (magit-sequence-insert-commit "pick" hash 'magit-sequence-pick))))
+ (magit-sequence-insert-sequence
+ (magit-file-line (expand-file-name "rebase-apply/original-commit" dir))
+ onto)))
(defun magit-rebase-patches ()
- (directory-files (magit-git-dir "rebase-apply") t "^[0-9]\\{4\\}$"))
+ (directory-files (expand-file-name "rebase-apply" (magit-gitdir))
+ t "^[0-9]\\{4\\}$"))
(defun magit-sequence-insert-sequence (stop onto &optional orig)
(let ((head (magit-rev-parse "HEAD")) done)
diff --git a/lisp/magit-submodule.el b/lisp/magit-submodule.el
index 08facb568d..33240c0d43 100644
--- a/lisp/magit-submodule.el
+++ b/lisp/magit-submodule.el
@@ -430,9 +430,10 @@ to recover from making a mistake here, but don't count on
it."
(if-let ((name (cadr (assoc module alist))))
;; Disregard if `magit-delete-by-moving-to-trash'
;; is nil. Not doing so would be too dangerous.
- (delete-directory (magit-git-dir
- (convert-standard-filename
- (concat "modules/" name)))
+ (delete-directory (convert-standard-filename
+ (expand-file-name
+ (concat "modules/" name)
+ (magit-gitdir)))
t t)
(error "BUG: Weird module name and/or path for %s" module)))))
(magit-refresh))))
@@ -688,8 +689,9 @@ These sections can be expanded to show the respective
commits."
;;; Utilities
(defun magit-submodule--maybe-reuse-gitdir (name path)
- (let ((gitdir
- (magit-git-dir (convert-standard-filename (concat "modules/" name)))))
+ (let ((gitdir (convert-standard-filename
+ (expand-file-name (concat "modules/" name)
+ (magit-gitdir)))))
(when (and (file-exists-p gitdir)
(not (file-exists-p path)))
(pcase (read-char-choice
- [nongnu] elpa/git-commit updated (eb66aed3b4 -> 564a5ceeb0), ELPA Syncer, 2023/03/17
- [nongnu] elpa/git-commit e23846ec2d 1/7: magit-save-repository-buffers: Cosmetics, ELPA Syncer, 2023/03/17
- [nongnu] elpa/git-commit 8606488578 2/7: magit-save-repository-buffers: Rev-parse only once per directory, ELPA Syncer, 2023/03/17
- [nongnu] elpa/git-commit e94b6ebfdb 6/7: Record diff-type in magit-diff-mode buffers, ELPA Syncer, 2023/03/17
- [nongnu] elpa/git-commit 564a5ceeb0 7/7: magit-git-debug: Fix key binding in docstring, ELPA Syncer, 2023/03/17
- [nongnu] elpa/git-commit c5c8f79167 4/7: magit-toplevel: Cosmetics, ELPA Syncer, 2023/03/17
- [nongnu] elpa/git-commit ff4710afa6 3/7: Deprecate magit-git-dir to avoid needlessly repeating work,
ELPA Syncer <=
- [nongnu] elpa/git-commit 623d335b4d 5/7: Memorize gitdir and topdir for each Magit buffer, ELPA Syncer, 2023/03/17