branch: elpa/magit
commit 8f6485c882184219bd221ae0b07fbe5a8b70a3a2
Author: Jonas Bernoulli <[email protected]>
Commit: Jonas Bernoulli <[email protected]>
magit--insert-blob-contents: Spin out new function
---
lisp/magit-files.el | 11 +++--------
lisp/magit-git.el | 9 +++++++++
2 files changed, 12 insertions(+), 8 deletions(-)
diff --git a/lisp/magit-files.el b/lisp/magit-files.el
index a8ed4865750..787fdb0ad93 100644
--- a/lisp/magit-files.el
+++ b/lisp/magit-files.el
@@ -151,16 +151,11 @@ REV is a revision or one of \"{worktree}\" or
\"{index}\"."
(format "%s.~%s~" file (subst-char-in-string ?/ ?_ rev))))
(defun magit--revert-blob-buffer (_ignore-auto _noconfirm)
- (let ((inhibit-read-only t)
- (file (magit-file-relative-name))
- (coding-system-for-read (or coding-system-for-read 'undecided)))
+ (let ((inhibit-read-only t))
(erase-buffer)
(save-excursion
- (magit-git-insert "cat-file" "-p"
- (if (equal magit-buffer-revision "{index}")
- (concat ":" file)
- (concat magit-buffer-revision ":" file))))
- (setq buffer-file-coding-system last-coding-system-used))
+ (magit--insert-blob-contents magit-buffer-revision
+ (magit-file-relative-name))))
(let ((buffer-file-name magit-buffer-file-name)
(after-change-major-mode-hook
(seq-difference after-change-major-mode-hook
diff --git a/lisp/magit-git.el b/lisp/magit-git.el
index 960a4f9e683..b41d07b4c6a 100644
--- a/lisp/magit-git.el
+++ b/lisp/magit-git.el
@@ -1335,6 +1335,15 @@ Sorted from longest to shortest CYGWIN name."
(mapcar (##split-string % " ")
(magit-git-lines "ls-files" "--stage" "--" file)))
+(defun magit--insert-blob-contents (rev file)
+ (let ((coding-system-for-read (or coding-system-for-read 'undecided)))
+ (magit-git-insert "cat-file" "-p"
+ (if (equal rev "{index}")
+ (concat ":" file)
+ (concat rev ":" file)))
+ (setq buffer-file-coding-system last-coding-system-used)
+ nil))
+
;;; Predicates
(defun magit-no-commit-p ()