From 12a193f8769ceb205261bd5804f5e5c808866a4f Mon Sep 17 00:00:00 2001 From: Michael Albinus Date: Sun, 18 Jul 2021 15:57:41 +0200 Subject: [PATCH] Fix problem in `shadow-define-literal-group' (Bug#49596) * lisp/shadowfile.el (shadow-make-fullname): HOST can also be a remote file name. Bug#49596. * test/lisp/shadowfile-tests.el (auth-source-save-behavior) (tramp-cache-read-persistent-data, tramp-persistency-file-name): Set them globally. (shadow-test06-literal-groups): Extend test. --- lisp/shadowfile.el | 8 ++++++-- test/lisp/shadowfile-tests.el | 15 +++++++++++---- 2 files changed, 17 insertions(+), 6 deletions(-) diff --git a/lisp/shadowfile.el b/lisp/shadowfile.el index f39f17329f2..ec3a27b9911 100644 --- a/lisp/shadowfile.el +++ b/lisp/shadowfile.el @@ -284,9 +284,13 @@ Argument can be a simple name, remote file name, or already a (defsubst shadow-make-fullname (hup &optional host name) "Make a Tramp style fullname out of HUP, a `tramp-file-name' structure. -Replace HOST, and NAME when non-nil." +Replace HOST, and NAME when non-nil. HOST can also be a remote file name." (let ((hup (copy-tramp-file-name hup))) - (when host (setf (tramp-file-name-host hup) host)) + (when host + (if (file-remote-p host) + (setq name (or name (and hup (tramp-file-name-localname hup))) + hup (tramp-dissect-file-name (file-remote-p host))) + (setf (tramp-file-name-host hup) host))) (when name (setf (tramp-file-name-localname hup) name)) (if (null (tramp-file-name-method hup)) (format diff --git a/test/lisp/shadowfile-tests.el b/test/lisp/shadowfile-tests.el index 268bb64f241..c571dc3e14b 100644 --- a/test/lisp/shadowfile-tests.el +++ b/test/lisp/shadowfile-tests.el @@ -69,12 +69,15 @@ (format "/mock::%s" temporary-file-directory))) "Temporary directory for Tramp tests.") -(setq password-cache-expiry nil +(setq auth-source-save-behavior nil + password-cache-expiry nil shadow-debug (or (getenv "EMACS_HYDRA_CI") (getenv "EMACS_EMBA_CI")) - tramp-verbose 0 ;; When the remote user id is 0, Tramp refuses unsafe temporary files. tramp-allow-unsafe-temporary-files (or tramp-allow-unsafe-temporary-files noninteractive) + tramp-cache-read-persistent-data t ;; For auth-sources. + tramp-persistency-file-name nil + tramp-verbose 0 ;; On macOS, `temporary-file-directory' is a symlinked directory. temporary-file-directory (file-truename temporary-file-directory) shadow-test-remote-temporary-file-directory @@ -643,7 +646,9 @@ guaranteed by the originator of a cluster definition." (expand-file-name "shadowfile-tests" shadow-test-remote-temporary-file-directory)) - mocked-input `(,cluster1 ,file1 ,cluster2 ,file2 ,(kbd "RET"))) + mocked-input + `(,cluster1 ,file1 ,cluster2 ,file2 + ,primary ,file1 ,(kbd "RET"))) (with-temp-buffer (set-visited-file-name file1) (call-interactively #'shadow-define-literal-group) @@ -657,7 +662,9 @@ guaranteed by the originator of a cluster definition." (should (member (format "/%s:%s" cluster1 (file-local-name file1)) (car shadow-literal-groups))) (should (member (format "/%s:%s" cluster2 (file-local-name file2)) - (car shadow-literal-groups)))) + (car shadow-literal-groups))) + ;; Bug#49596. + (should (member (concat primary file1) (car shadow-literal-groups)))) ;; Cleanup. (shadow--tests-cleanup)))) -- 2.39.2