magit-wip-mode over TRAMP never results in after-save commits.
When magit-wip-mode is enabled, the globalized minor mode
magit-wip-after-save-mode should enable
magit-wip-after-save-local-mode in all buffers where the turn-on function
magit-wip-after-save-local-mode-turn-on returns true.
- Open a git-tracked file over TRAMP.
magit-wip-modein the buffer.
- Evaluate the buffer local variable
after-save-hook. I posit that it will not contain
(magit-file-tracked-p buffer-file-name). I posit that it will return nil.
GNU Emacs v29.0.92 Doom core v3.0.0-pre Doom modules v23.03.0-pre
(Yes, I know I’m on an unsupported Emacs version, but the lisp code in question has been in place for years so that’s probably not relevant.)
The turn-on function
magit-wip-after-save-local-mode-turn-on only enables
magit-wip-after-save-local-mode if the following is true:
(magit-file-tracked-p buffer-file-name). But it will never be true with that argument in a TRAMP buffer that is visiting a file over ssh/scp.
Elsewhere in the
magit repo, the TRAMP issue has been addressed, for example in this commit, where the call has been changed to
(magit-file-tracked-p (file-relative-name file)). This one does return
t when visiting a git-tracked file via TRAMP.
It looks like the offending code was changed on 1 April 2023. While the commit message doesn’t mention the TRAMP issue and the commit is part of a performance-related refactoring, it looks like some (edited: all->some) references to the buffer file go through
I intend to bump the magit version pin and give it a shot, but before I open that can of worms, I wanted to see if anyone else has tried to use
magit-wip over TRAMP in the last year or so. If it works for you, please report the values that result from “Steps to reproduce” above because in that case I’m missing some piece of the puzzle.
magit did not resolve the issue, which is apparent after looking more closely at the revised
magit-wip-after-save-local-mode-turn-on code: it still calls
It looks like upstream tried to resolve this issue for other parts of
magit-wip was missed.
For now I tried to replace all occurences in
(magit-file-tracked-p buffer-file-name) with
(magit-file-tracked-p (file-relative-name buffer-file-name). It seems to be working, but it makes me nervous to make this change not knowing the codebase well. I’m usually pretty cavalier about such things, but a misbehaving
magit-wip could very easily cause a major headache.
I’d still like to hear from someone else about this, if only to confirm the issue. But it looks like I’ll have to file a bug report upstream. I’m just surprised that I’ve found no mentions of this anywhere. Can it be that I’m the only person who noticed that
magic-wip-mode doesn’t work over TRAMP?