magit-filenotify icon indicating copy to clipboard operation
magit-filenotify copied to clipboard

Breaks when using TRAMP

Open PythonNut opened this issue 10 years ago • 12 comments

If magit-filenotify is enabled and magit-status is called on a TRAMP directory, the buffer will be caught in an infinite loop because of the extra delay of TRAMP causing magit-filenotify to trigger its own refresh conditions.

PythonNut avatar Jun 02 '15 17:06 PythonNut

@PythonNut Can file notifications work at all for remote directories? I guess not, so a simple yet proper fix was to not activate magit-filenotify-mode if (file-remote-p default-directory) returns t, no?

tsdh avatar Aug 12 '15 07:08 tsdh

@tsdh I think it does work doesn't it? The fact that it loops indicates that the file notification system is working, right?

PythonNut avatar Aug 12 '15 15:08 PythonNut

@PythonNut Good point. :-)

Hm, I just tried to reproduce the issue by finding a git working copy directory on a remote server and doing M-x magit-status but I get the error: tramp-file-name-handler: No file notification program found on /ssh:horn@jiffybox:.

And now I tried on a different remote but then M-x magit-status asks me for which project to open the status buffer meaning that it didn't even recognize that the remote file or directory is tracked by git...

tsdh avatar Aug 12 '15 15:08 tsdh

@PythonNut Well, actually I don't understand your description completely. magit-filenotify's refresh conditions are "something in a repo dir changed on disk". How does firing up or refreshing a magit status buffer change something on disk?

But anyway, it is possible that my PR #12 already solves this issue by accident. Essentially, it delays magit status buffer refreshes as long as new file notifications keep coming in in a short period of time. So please test if you find some time.

tsdh avatar Aug 12 '15 15:08 tsdh

@tsdh git uses a lockfile (/.git/index.lock) to ensure that operations don't collide, so checking the status will create and destroy /.git/index.lock, which triggers the filenotify listener.

I'll look into your PR when I get a few spare minutes.

PythonNut avatar Aug 12 '15 16:08 PythonNut

The .git directory is not watched at all with the current code so that shouldn't be the issue.

tsdh avatar Aug 12 '15 16:08 tsdh

@PythonNut Good point. :-)

Hm, I just tried to reproduce the issue by finding a git working copy directory on a remote server and doing M-x magit-status but I get the error: tramp-file-name-handler: No file notification program found on /ssh:horn@jiffybox:.

Actually magit-filenotify works fine on remote repos, if gvfs-monitor-dir is installed.

It just seems to hang if it has to handle too many remote directories (A SSH+gvfs-monitor-dir process is spawned for every subdir). Actually its not usable on big repos.

I use GNU Emacs 24.5 and the tramp master branch.

juergenhoetzel avatar Feb 16 '16 07:02 juergenhoetzel

Not sure how relevant this is since I haven't been following this thread, but

The .git directory is not watched at all with the current code so that shouldn't be the issue.

The file watching mechanism may cast a wider net than you expect, cf https://github.com/magit/magit/issues/2454#issuecomment-168241128 and http://debbugs.gnu.org/cgi/bugreport.cgi?bug=22454

npostavs avatar Feb 16 '16 14:02 npostavs

http://debbugs.gnu.org/cgi/bugreport.cgi?bug=22454 is fixed. Is this still an issue?

ruediger avatar Jan 29 '17 13:01 ruediger

http://debbugs.gnu.org/cgi/bugreport.cgi?bug=22454 is fixed.

It's not "fixed" exactly, I closed it because there was no bug in Emacs: https://debbugs.gnu.org/cgi/bugreport.cgi?bug=22454#13

So depending on the filesystem, it's possible that changes inside .git/ would trigger notifications events about the .git/ directory changing, even if Emacs is not listening for changes inside .git/. I'm not sure how relevant that is to this bug.

npostavs avatar Jan 29 '17 14:01 npostavs

I just got the No file notification program found error when I tried to use magit-status on a remote machine through TRAMP. Is there any way to use Magit without the notification monitoring?

alphapapa avatar Mar 12 '17 21:03 alphapapa

@alphapapa magit-filenotify is just an optional mode. You can run Magit without it. M-x magit-filenotify-mode RET will disable it. Remove it from magit-status-hook-mode to no longer automatically start it.

ruediger avatar Mar 21 '17 02:03 ruediger