Bug#1016081: elpa-magit: Magit saves wrong buffers for remote repository
Package: elpa-magit
Version: 3.3.0-1
Severity: normal
Tags: patch
X-Debbugs-Cc: Toby Speight <T.M.Speight.90@cantab.net>
File: /usr/share/emacs/site-lisp/elpa-src/magit-3.3.0/magit-mode.el
When working remotely over SSH, I find that Magit offers to save only
local files, rather than the ones on the host where Git is running.
The problem stems from `magit-save-repository-buffers', which begins
around line 1208:
/--------
| (when-let ((topdir (magit-rev-parse-safe "--show-toplevel")))
| (let ((remote (file-remote-p topdir))
\--------
`topdir' is the output from "git rev-parse --show-toplevel", which is a
pathname _on the remote machine_, without any adornment. So `remote' is
always nil, even for such a repository.
I get the desired behavour if I make the following changes, which could
be a candidate for upstream:
--- /usr/share/emacs/site-lisp/elpa-src/magit-3.3.0/magit-mode.el 2022-07-26 08:58:43.534569844 +0100
+++ /usr/share/emacs/site-lisp/elpa-src/magit-3.3.0/magit-mode.el 2022-07-26 08:58:43.534569844 +0100
@@ -1206,7 +1206,7 @@
argument (the prefix) non-nil means save all with no questions."
(interactive "P")
(when-let ((topdir (magit-rev-parse-safe "--show-toplevel")))
- (let ((remote (file-remote-p topdir))
+ (let ((remote (file-remote-p default-directory))
(save-some-buffers-action-alist
`((?Y (lambda (buffer)
(with-current-buffer buffer
@@ -1229,7 +1229,7 @@
;; therefore has to come after the above to avoid
;; unnecessarily waiting for unrelated hosts.
(file-exists-p (file-name-directory buffer-file-name))
- (string-prefix-p topdir (file-truename buffer-file-name))
+ (string-prefix-p topdir (file-local-name (file-truename buffer-file-name)))
(equal (magit-rev-parse-safe "--show-toplevel")
topdir)))))))
-- System Information:
Debian Release: bookworm/sid
APT prefers testing
APT policy: (900, 'testing'), (400, 'unstable')
Architecture: amd64 (x86_64)
Kernel: Linux 5.10.0-6-amd64 (SMP w/8 CPU threads)
Locale: LANG=en_GB.UTF-8, LC_CTYPE=en_GB.UTF-8 (charmap=UTF-8), LANGUAGE not set
Shell: /bin/sh linked to /bin/dash
Init: systemd (via /run/systemd/system)
Versions of packages elpa-magit depends on:
ii dh-elpa-helper 2.0.10
ii elpa-dash 2.19.1+dfsg-1
ii elpa-git-commit 3.3.0-1
ii elpa-magit-section 3.3.0-1
ii elpa-transient 0.3.7-1
ii elpa-with-editor 3.0.5-1
ii emacsen-common 3.0.4
ii git 1:2.35.1-1
elpa-magit recommends no packages.
elpa-magit suggests no packages.
-- no debconf information
Reply to: