0

Unfortunately, the vc-mode in my mode-line is not being updated when checking out a branch, it still points to the older branch. revert all open buffers fixes than but I can't find a hook to attach the reverting to.

Is there a way to execute a function whenever I do a checkout through Magit?

  • 5
  • Thank you, I tried all workarounds but none of them worked unfortunately. – SFbay007 Nov 9 '17 at 22:37
  • What do you mean by "none of them work". Two of the proposals are about always disabling the feature, and while that might not be what you want, they should just work. (You might have to restart though.) – tarsius Nov 10 '17 at 20:08
  • I have just added another resource to my answer on the other issue. – tarsius Nov 10 '17 at 20:10
  • What I meant is that all other solutions (besides disabling the feature) did not work. In the page that you sent there are two solutions, either implementing a function and hook it (add-hook 'magit-update-uncommitted-buffer-hook 'magit-refresh-vc-mode-line ) or add this hook (add-hook 'magit-update-uncommitted-buffer-hook 'vc-refresh-state)....none of these solutions worked for me. The VC info on mode line stayed unchanged. – SFbay007 Nov 10 '17 at 20:47
1

The easiest way to get what you want is (setq auto-revert-check-vc-info t), but that comes with a performance penalty.

Some alternative methods and details are mentioned on the following pages. Please note that some the presented code might need some adjustments, especially if you are using a different Emacs version than whatever I was using at the time when I wrote those proof-of-concepts.

Also note that this is a VC feature that is not working properly. The only reason why I might (eventually be forced to) write a replacement for Magit is that users keep reporting this as a Magit issue.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.