From 51fffcb3a97b5d16dc48a6d38726707a316e6099 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C3=93scar=20Fuentes?= Date: Sun, 27 Jun 2010 02:20:40 +0200 Subject: [PATCH] A better way for updating the VC modeline Revision 51a1b6d8 introduced a change that reverts all buffers after a commit operation for refreshing the VC modeline info. This can be slow (because refontification, etc) and have side effects (changes on display settings for some modes.) Instead of reverting the buffer, we now call `vc-find-file-hook' which is much faster and have no side effects. We now update the VC modeline info after resetting, because that operation may change the VC status without changing the file contents (commit a change and then reset to HEAD^, for instance.) --- magit.el | 18 ++++++++++++++---- 1 file changed, 14 insertions(+), 4 deletions(-) diff --git a/magit.el b/magit.el index 3af0ad3b..6c291a85 100644 --- a/magit.el +++ b/magit.el @@ -1805,6 +1805,15 @@ Please see the manual for a complete description of Magit. (ignore-errors (revert-buffer t t nil)))))) +(defun magit-update-vc-modeline (dir) + (dolist (buffer (buffer-list)) + (when (and buffer + (buffer-file-name buffer) + (magit-string-has-prefix-p (buffer-file-name buffer) dir)) + (with-current-buffer buffer + (ignore-errors + (vc-find-file-hook)))))) + (defvar magit-refresh-needing-buffers nil) (defvar magit-refresh-pending nil) @@ -2833,9 +2842,10 @@ and staging area are lost. (or (magit-default-rev) "HEAD^")) current-prefix-arg)) - (if revision - (magit-run-git "reset" (if hard "--hard" "--soft") - (magit-rev-to-git revision)))) + (when revision + (magit-run-git "reset" (if hard "--hard" "--soft") + (magit-rev-to-git revision)) + (magit-update-vc-modeline default-directory))) (defun magit-reset-head-hard (revision) "Switch 'HEAD' to REVISION, losing all changes. @@ -3210,7 +3220,7 @@ Prefix arg means justify as well." (bury-buffer) (when (file-exists-p ".git/MERGE_MSG") (delete-file ".git/MERGE_MSG")) - (magit-revert-buffers default-directory t) + (magit-update-vc-modeline default-directory) (when magit-pre-log-edit-window-configuration (set-window-configuration magit-pre-log-edit-window-configuration) (setq magit-pre-log-edit-window-configuration nil))))