emacs-elpa-diffs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[nongnu] elpa/git-commit 7aa314c 4/8: Fix worktree commands when using t


From: ELPA Syncer
Subject: [nongnu] elpa/git-commit 7aa314c 4/8: Fix worktree commands when using tramp
Date: Tue, 12 Oct 2021 14:57:47 -0400 (EDT)

branch: elpa/git-commit
commit 7aa314cd61142c3d0766d650ac560943f918e63f
Author: Jonas Bernoulli <jonas@bernoul.li>
Commit: Jonas Bernoulli <jonas@bernoul.li>

    Fix worktree commands when using tramp
    
    Closes #4326.
---
 lisp/magit-git.el      | 10 +++++++---
 lisp/magit-worktree.el |  9 ++++++---
 2 files changed, 13 insertions(+), 6 deletions(-)

diff --git a/lisp/magit-git.el b/lisp/magit-git.el
index 84a6c51..c399b05 100644
--- a/lisp/magit-git.el
+++ b/lisp/magit-git.el
@@ -1823,14 +1823,18 @@ PATH has to be relative to the super-repository."
   (magit-git-string "submodule--helper" "name" path))
 
 (defun magit-list-worktrees ()
-  (let (worktrees worktree)
+  (let ((remote (file-remote-p default-directory))
+        worktrees worktree)
     (dolist (line (let ((magit-git-global-arguments
                          ;; KLUDGE At least in v2.8.3 this triggers a segfault.
                          (remove "--no-pager" magit-git-global-arguments)))
                     (magit-git-lines "worktree" "list" "--porcelain")))
       (cond ((string-prefix-p "worktree" line)
-             (push (setq worktree (list (substring line 9) nil nil nil))
-                   worktrees))
+             (let ((path (substring line 9)))
+               (when remote
+                 (setq path (concat remote path)))
+               (setq worktree (list path nil nil nil))
+               (push worktree worktrees)))
             ((string-equal line "bare")
              (let* ((default-directory (car worktree))
                     (wt (and (not (magit-get-boolean "core.bare"))
diff --git a/lisp/magit-worktree.el b/lisp/magit-worktree.el
index 47f71b6..556448e 100644
--- a/lisp/magit-worktree.el
+++ b/lisp/magit-worktree.el
@@ -64,7 +64,7 @@ Used by `magit-worktree-checkout' and 
`magit-worktree-branch'."
      (list (funcall magit-worktree-read-directory-name-function
                     (format "Checkout %s in new worktree: " branch))
            branch)))
-  (magit-run-git "worktree" "add" (expand-file-name path) branch)
+  (magit-run-git "worktree" "add" (magit--expand-worktree path) branch)
   (magit-diff-visit-directory path))
 
 ;;;###autoload
@@ -76,7 +76,7 @@ Used by `magit-worktree-checkout' and 
`magit-worktree-branch'."
      ,@(magit-branch-read-args "Create and checkout branch")
      ,current-prefix-arg))
   (magit-run-git "worktree" "add" (if force "-B" "-b")
-                 branch (expand-file-name path) start-point)
+                 branch (magit--expand-worktree path) start-point)
   (magit-diff-visit-directory path))
 
 ;;;###autoload
@@ -93,7 +93,7 @@ Used by `magit-worktree-checkout' and 
`magit-worktree-branch'."
       (user-error "You may not move the main working tree")
     (let ((preexisting-directory (file-directory-p path)))
       (when (and (zerop (magit-call-git "worktree" "move" worktree
-                                        (expand-file-name path)))
+                                        (magit--expand-worktree path)))
                  (not (file-exists-p default-directory))
                  (derived-mode-p 'magit-status-mode))
         (kill-buffer)
@@ -143,6 +143,9 @@ then show it in Dired instead."
                          :test #'equal :key #'car)))))
   (magit-diff-visit-directory worktree))
 
+(defun magit--expand-worktree (path)
+  (magit-convert-filename-for-git (expand-file-name path)))
+
 ;;; Sections
 
 (defvar magit-worktree-section-map



reply via email to

[Prev in Thread] Current Thread [Next in Thread]