mirror of
https://github.com/doomemacs/doomemacs
synced 2025-08-01 12:17:25 -05:00
Prevent magit trying to revert non-existent file buffers
This commit is contained in:
@ -48,12 +48,16 @@
|
|||||||
(defun +magit--revert-buffer (buffer)
|
(defun +magit--revert-buffer (buffer)
|
||||||
(with-current-buffer buffer
|
(with-current-buffer buffer
|
||||||
(kill-local-variable '+magit--stale-p)
|
(kill-local-variable '+magit--stale-p)
|
||||||
(if (buffer-file-name (buffer-base-buffer))
|
(let ((buffer (or (buffer-base-buffer) (current-buffer))))
|
||||||
(and (or (not (buffer-modified-p))
|
(if-let (file (buffer-file-name buffer))
|
||||||
(y-or-n-p "Version control data is outdated in this buffer, but it is unsaved. Revert anyway?"))
|
(and (file-exists-p file)
|
||||||
(revert-buffer t t))
|
(or (not (buffer-modified-p buffer))
|
||||||
(when (and vc-mode (fboundp 'vc-refresh-state))
|
(y-or-n-p
|
||||||
(vc-refresh-state)))))
|
(format "Version control data is outdated in %s, but it is unsaved. Revert anyway?"
|
||||||
|
buffer)))
|
||||||
|
(revert-buffer t t))
|
||||||
|
(when (and vc-mode (fboundp 'vc-refresh-state))
|
||||||
|
(vc-refresh-state))))))
|
||||||
|
|
||||||
;;;###autoload
|
;;;###autoload
|
||||||
(defun +magit-mark-stale-buffers-h ()
|
(defun +magit-mark-stale-buffers-h ()
|
||||||
|
Reference in New Issue
Block a user