From d40125c9f9955ab55a5a823ae812d54bc575d7da Mon Sep 17 00:00:00 2001 From: 10sr <8.slashes@gmail.com> Date: Tue, 11 Dec 2018 18:18:12 +0900 Subject: [PATCH] Implement move --- emacs.el | 21 +++++++++++++-------- 1 file changed, 13 insertions(+), 8 deletions(-) diff --git a/emacs.el b/emacs.el index 39b88fb..02468a2 100644 --- a/emacs.el +++ b/emacs.el @@ -2164,20 +2164,25 @@ initializing." (interactive) (let* ((id (tabulated-list-get-id)) (path (plist-get id :worktree))) - (when path - (if (file-directory-p path) - (dired path) - (error "Directory not found: %s" path))))) + (cl-assert path nil "No worktree info at point") + (cl-assert (file-directory-p path) t "Directory not found") + (dired path))) (defun git-worktree-mode-move () "Move worktree at point to a new location." (interactive) (let* ((id (tabulated-list-get-id)) (path (plist-get id :worktree))) - (when path - (if (file-directory-p path) - (dired path) - (error "Directory not found: %s" path))))) + (cl-assert path nil "No worktree info at point") + (cl-assert (file-directory-p path) t "Directory not found") + (let ((new (read-file-name (format "New name for worktree %s: " + path)))) + (with-temp-buffer + (git-worktree--call-process "worktree" + "move" + path + (expand-file-name new))) + (revert-buffer)))) (defvar git-worktree-mode-map (let ((map (make-sparse-keymap)))