I'm trying to track down an issue which might be caused by magit.

I work on multiple machines, and on each machine I have an emacs running, each of which has some magit buffers open. I keep machines synchronized using Unison, which propagates changes from each machine to the others. As long as I make changes only on one machine at a time, it works great.

However, I have noticed that sometimes, I have done some commits, pulls, or pushes on machine A, and Unison refuses to propagate the changes to machine B, because Unison believes that file .git/index has changed not only on machine A (where I made changes myself) but also on machine B (where I believe I have done nothing). I am wondering if perhaps magit is writing the .git/index file on machine B.

ETA: At minimum, the modification time of the file on machine B has changed (not just the access time). I don't know if the contents have changed, as I don't usually have a third version to compare it to.

Major search engines and the magit issue tracker have not enlightened me.

My question: Could an otherwise idle magit write file .git/index, and if so, can it be stopped?

  • Are the files actually different or is it just their access times that differ? – Andrew Swann Jan 29 '18 at 8:53
  • @AndrewSwann more than just access times. Edited to add what I know. – Norman Ramsey Jan 29 '18 at 14:17
  • Do you not use Emacs on machine B at all when this happens? If you edit files then Magit may run git, even if you "don't use Magit". And VC may even do so when you don't do anything at all (using timers). Have you disabled VC for Git repositories? – tarsius Jan 29 '18 at 14:51
  • @tarsius emacs is running continuously on machine B, but I am not driving it. One hopes all the buffers are sitting idle, but perhaps not. I have not consciously enabled VC mode, but neither have I disabled it. I have now deployed (eval-after-load "vc" (setq vc-handled-backends (delete 'Git vc-handled-backends))); will let you know if it helps. – Norman Ramsey Jan 30 '18 at 1:50
  • @tarsius I think VC was the culprit. At least, after disabling it, I no longer get the symptom. Care to make your comment an answer so I can accept it? – Norman Ramsey Feb 11 '18 at 23:00

If you don't do anything at all in Emacs, then Magit should not do anything (that touches the index or otherwise). VC on the other hand uses timers to periodically refresh some information and calls git commands to do so and some of those touch the index.

Provided VC was the cause of this issue, then deleting Git from vc-handled-backends would likely fix it.

It is possible that the alternative implementation of some VC functionality that I provided here does not touch the index, just in case your really want to see Git-master (or similar) in the mode line. But I don't know for sure and that function might also have other issues.

  • Deleting Git from vc-handled-backends does indeed fix the issue. Thank you! – Norman Ramsey Feb 14 '18 at 15:58

Yes, although it's not really Magit's fault. This index file is a cache of information used to speed up a number of common git operations, and as such it might be updated by any of the common git operations. I can't give you an exact list of these operations, but the git source code has a document which describes the information stored in the file (https://github.com/git/git/blob/master/Documentation/technical/index-format.txt) from which it is possible to make some guesses.

In particular, the index stores information about untracked files and the file-system monitor. Both of these can be updated whenever you run simple commands like git status.

I would simply not sync the index file; it's just a cache and git itself will update it as needed. The other alternative is to use git itself to push commits between repositories, rather than using another syncing program to do it.

  • The index file may be just a cache---but if I perform git operations, those operations don't propagate unless I propagate the index file. – Norman Ramsey Jan 30 '18 at 1:49
  • Do you think that magit is running git status while otherwise idle? Or similar? – Norman Ramsey Jan 30 '18 at 1:55

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.