|
@@ -2058,14 +2058,14 @@ use for the buffer. It defaults to \"*recetf-show*\"." |
|
|
(defun git-worktree-get-current-trees () |
|
|
(defun git-worktree-get-current-trees () |
|
|
"Get current worktree list." |
|
|
"Get current worktree list." |
|
|
(with-temp-buffer |
|
|
(with-temp-buffer |
|
|
(let ((trees nil) |
|
|
|
|
|
(status (call-process "git" |
|
|
|
|
|
|
|
|
(let ((status (call-process "git" |
|
|
nil |
|
|
nil |
|
|
t |
|
|
t |
|
|
nil |
|
|
nil |
|
|
"worktree" "list" "--porcelain"))) |
|
|
"worktree" "list" "--porcelain"))) |
|
|
(cl-assert (eq status 0)) |
|
|
|
|
|
(goto-char (point-min)) |
|
|
|
|
|
|
|
|
(cl-assert (eq status 0))) |
|
|
|
|
|
(goto-char (point-min)) |
|
|
|
|
|
(let ((trees nil)) |
|
|
(save-match-data |
|
|
(save-match-data |
|
|
(while (not (eq (point) (point-max))) |
|
|
(while (not (eq (point) (point-max))) |
|
|
(let ((worktree nil) |
|
|
(let ((worktree nil) |
|
@@ -2085,6 +2085,21 @@ use for the buffer. It defaults to \"*recetf-show*\"." |
|
|
)) |
|
|
)) |
|
|
trees))) |
|
|
trees))) |
|
|
|
|
|
|
|
|
|
|
|
(defun git-worktree--call-process (args) |
|
|
|
|
|
"Start git process synchronously with ARGS. |
|
|
|
|
|
|
|
|
|
|
|
Raise error when git process ends with non-zero status. |
|
|
|
|
|
Any output will be written to current buffer." |
|
|
|
|
|
(let ((status (apply 'call-process |
|
|
|
|
|
"git" |
|
|
|
|
|
nil |
|
|
|
|
|
t |
|
|
|
|
|
nil |
|
|
|
|
|
args))) |
|
|
|
|
|
(cl-assert (eq status 0) |
|
|
|
|
|
nil |
|
|
|
|
|
(buffer-substring-no-properties (point-min) (point-max))))) |
|
|
|
|
|
|
|
|
(defun git-worktree--get-repository-root (dir) |
|
|
(defun git-worktree--get-repository-root (dir) |
|
|
"Resolve repository root of DIR. |
|
|
"Resolve repository root of DIR. |
|
|
|
|
|
|
|
@@ -2097,11 +2112,11 @@ If DIR is not inside of any git repository, signal an error." |
|
|
t |
|
|
t |
|
|
nil |
|
|
nil |
|
|
"rev-parse" "--show-toplevel"))) |
|
|
"rev-parse" "--show-toplevel"))) |
|
|
(goto-char (point-min)) |
|
|
|
|
|
(cl-assert (eq status 0) |
|
|
(cl-assert (eq status 0) |
|
|
nil |
|
|
nil |
|
|
(buffer-substring-no-properties (point-min) (point-max))) |
|
|
|
|
|
(buffer-substring-no-properties (point-at-bol) (point-at-eol))))) |
|
|
|
|
|
|
|
|
(buffer-substring-no-properties (point-min) (point-max)))) |
|
|
|
|
|
(goto-char (point-min)) |
|
|
|
|
|
(buffer-substring-no-properties (point-at-bol) (point-at-eol)))) |
|
|
;;(git-worktree--get-repository-root default-directory) |
|
|
;;(git-worktree--get-repository-root default-directory) |
|
|
|
|
|
|
|
|
(defun git-worktree-open-noselect (&optional directory) |
|
|
(defun git-worktree-open-noselect (&optional directory) |
|
@@ -2142,9 +2157,9 @@ initializing." |
|
|
("Worktree" ,worktree-max-size t) |
|
|
("Worktree" ,worktree-max-size t) |
|
|
("Branch" ,branch-max-size t) |
|
|
("Branch" ,branch-max-size t) |
|
|
("Head" -1 t) |
|
|
("Head" -1 t) |
|
|
])) |
|
|
|
|
|
(git-worktree-mode) |
|
|
|
|
|
(current-buffer))))) |
|
|
|
|
|
|
|
|
]))) |
|
|
|
|
|
(git-worktree-mode) |
|
|
|
|
|
(current-buffer)))) |
|
|
;; ((:worktree "/Users/10sr/.dotfiles" :head "5e7457a8d49ef6a517cdf39d038ba5fdf98dc68e" :branch "refs/heads/master") (:worktree "/Users/10sr/.dotfiles/b1" :head "fa7d868076d807692e35f82ae23596c903fd1117" :branch "refs/heads/b1")) |
|
|
;; ((:worktree "/Users/10sr/.dotfiles" :head "5e7457a8d49ef6a517cdf39d038ba5fdf98dc68e" :branch "refs/heads/master") (:worktree "/Users/10sr/.dotfiles/b1" :head "fa7d868076d807692e35f82ae23596c903fd1117" :branch "refs/heads/b1")) |
|
|
(defun git-worktree-open (&optional directory) |
|
|
(defun git-worktree-open (&optional directory) |
|
|
"Open git worktree list buffer. |
|
|
"Open git worktree list buffer. |
|
@@ -2159,15 +2174,20 @@ initializing." |
|
|
(defun git-worktree-mode-go () |
|
|
(defun git-worktree-mode-go () |
|
|
"Go to worktree directory at point." |
|
|
"Go to worktree directory at point." |
|
|
(interactive) |
|
|
(interactive) |
|
|
(let ((id (tabulated-list-get-id))) |
|
|
|
|
|
(when id |
|
|
|
|
|
(dired (plist-get id :worktree))))) |
|
|
|
|
|
|
|
|
(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))))) |
|
|
|
|
|
|
|
|
|
|
|
(defun git-worktree-mode-move ()) |
|
|
|
|
|
|
|
|
(defvar git-worktree-mode-map |
|
|
(defvar git-worktree-mode-map |
|
|
(let ((map (make-sparse-keymap))) |
|
|
(let ((map (make-sparse-keymap))) |
|
|
(suppress-keymap map) |
|
|
(suppress-keymap map) |
|
|
(define-key map (kbd "C-m") 'git-worktree-mode-go) |
|
|
(define-key map (kbd "C-m") 'git-worktree-mode-go) |
|
|
(define-key map "R" 'git-worktree-mode-rename) |
|
|
|
|
|
|
|
|
(define-key map "R" 'git-worktree-mode-move) |
|
|
(define-key map "D" 'git-worktree-mode-remove) |
|
|
(define-key map "D" 'git-worktree-mode-remove) |
|
|
(define-key map (kbd "C-g") 'git-worktree-mode-close) |
|
|
(define-key map (kbd "C-g") 'git-worktree-mode-close) |
|
|
(define-key map "/" 'isearch-forward) |
|
|
(define-key map "/" 'isearch-forward) |
|
|