I've recently upgraded to Magit 2.10.3 and Emacs 25.2.1.
My full config is: Magit 2.10.3, Git 2.13.5 (Apple Git-94), Emacs 25.2.1, darwin.
I was previously on Magit 2.3.1 and Emacs 24.4.1.
Now, when I do a
magit-status any open buffers within the project are changed to have auto-revert mode turned on.
Previously, the behaviour was only to revert buffers when Magit operations were performed (eg using Magit to checkout a different commit would revert any buffers whose files had changed). auto-revert mode was never turned on (or if it was it was only temporarily, and I didn't notice it).
Is there a way to get the old behaviour?
Based on tarsius's answer, I've done the following:
(with-eval-after-load 'magit-autorevert (defalias 'magit-auto-revert-buffers 'revert-all-unmodified-buffers) (magit-auto-revert-mode -1))
revert-all-unmodified-buffers is something I had lying around:
(defun _revert-all-buffers (buffer-predicate) (dolist (buf (buffer-list)) (with-current-buffer buf (when (and (buffer-file-name) (funcall buffer-predicate buf)) (revert-buffer t t t) ))) (message "Refreshed open files.")) (defun revert-all-unmodified-buffers () "Refreshes all open unmodified buffers from their files." (interactive) (_revert-all-buffers (lambda (b) (not (buffer-modified-p b)))))
This kind of works. I guess I could change things so that I only revert buffers in the project directory.
One thing I noticed: whenever I refresh the Magit Status buffer, files get reverted. I don't really want that.
I believe I have restored the old behaviour, by turning off
magit-auto-revert-mode and by doing a
(defalias 'magit-auto-revert-buffers ...) that reverts buffers within the repo:
(defun _revert-all-buffers (buffer-predicate) (dolist (buf (buffer-list)) (with-current-buffer buf (when (and (buffer-file-name) (funcall buffer-predicate buf)) (condition-case e (revert-buffer t t t) (error (message "%s" e)))))) (message "Refreshed open files.")) (defun revert-all-unmodified-buffers-in-git-repo () "Refreshes all open modified buffers in current buffer's Git repo from their files." (interactive) (_revert-all-buffers (lambda (b) (and (not (buffer-modified-p b)) (magit-auto-revert-repository-buffer-p b))))) (with-eval-after-load 'magit-autorevert (magit-auto-revert-mode 0) (defalias 'magit-auto-revert-buffers 'revert-all-unmodified-buffers-in-git-repo))
Thanks, tarsius, for pointing me in the right direction.
I wonder if something like this could be supported without having to hack things? (My concern is that my hack might break when I next update Magit.)
magit-auto-revert-mode. The effect was to completely turn off reverting — even when a Magit operation changes files.