update of packages
This commit is contained in:
@@ -1,6 +1,6 @@
|
||||
;;; magit-worktree.el --- Worktree support -*- lexical-binding:t -*-
|
||||
|
||||
;; Copyright (C) 2008-2022 The Magit Project Contributors
|
||||
;; Copyright (C) 2008-2023 The Magit Project Contributors
|
||||
|
||||
;; Author: Jonas Bernoulli <jonas@bernoul.li>
|
||||
;; Maintainer: Jonas Bernoulli <jonas@bernoul.li>
|
||||
@@ -33,7 +33,7 @@
|
||||
(defcustom magit-worktree-read-directory-name-function #'read-directory-name
|
||||
"Function used to read a directory for worktree commands.
|
||||
This is called with one argument, the prompt, and can be used
|
||||
to e.g. use a base directory other than `default-directory'.
|
||||
to, e.g., use a base directory other than `default-directory'.
|
||||
Used by `magit-worktree-checkout' and `magit-worktree-branch'."
|
||||
:package-version '(magit . "3.0.0")
|
||||
:group 'magit-commands
|
||||
@@ -145,14 +145,14 @@ then show it in Dired instead."
|
||||
|
||||
;;; Sections
|
||||
|
||||
(defvar magit-worktree-section-map
|
||||
(let ((map (make-sparse-keymap)))
|
||||
(magit-menu-set map [magit-visit-thing] #'magit-worktree-status "Visit %s")
|
||||
(magit-menu-set map [magit-delete-thing] #'magit-worktree-delete "Delete %m")
|
||||
(define-key-after map [separator-magit-worktree] menu-bar-separator)
|
||||
(magit-menu-set map [magit-worktree ] #'magit-worktree "Worktree commands...")
|
||||
map)
|
||||
"Keymap for `worktree' sections.")
|
||||
(defvar-keymap magit-worktree-section-map
|
||||
:doc "Keymap for `worktree' sections."
|
||||
"<remap> <magit-delete-thing>" #'magit-worktree-delete
|
||||
"<remap> <magit-visit-thing>" #'magit-worktree-status
|
||||
"<4>" (magit-menu-item "Worktree commands..." #'magit-worktree)
|
||||
"<3>" '(menu-item "--")
|
||||
"<2>" (magit-menu-item "Delete %m" #'magit-worktree-delete)
|
||||
"<1>" (magit-menu-item "Visit %s" #'magit-worktree-status))
|
||||
|
||||
(defun magit-insert-worktrees ()
|
||||
"Insert sections for all worktrees.
|
||||
@@ -163,29 +163,45 @@ If there is only one worktree, then insert nothing."
|
||||
(magit-insert-heading "Worktrees:")
|
||||
(let* ((cols
|
||||
(mapcar
|
||||
(pcase-lambda (`(,path ,barep ,commit ,branch))
|
||||
(cons (cond
|
||||
(branch (propertize
|
||||
branch 'font-lock-face
|
||||
(if (equal branch (magit-get-current-branch))
|
||||
'magit-branch-current
|
||||
'magit-branch-local)))
|
||||
(commit (propertize (magit-rev-abbrev commit)
|
||||
'font-lock-face 'magit-hash))
|
||||
(barep "(bare)"))
|
||||
path))
|
||||
(lambda (config)
|
||||
(pcase-let ((`(,_ ,commit ,branch ,bare) config))
|
||||
(cons (cond
|
||||
(branch
|
||||
(propertize
|
||||
branch 'font-lock-face
|
||||
(if (equal branch (magit-get-current-branch))
|
||||
'magit-branch-current
|
||||
'magit-branch-local)))
|
||||
(commit
|
||||
(propertize (magit-rev-abbrev commit)
|
||||
'font-lock-face 'magit-hash))
|
||||
(bare "(bare)"))
|
||||
config)))
|
||||
worktrees))
|
||||
(align (1+ (-max (--map (string-width (car it)) cols)))))
|
||||
(pcase-dolist (`(,head . ,path) cols)
|
||||
(magit-insert-section (worktree path)
|
||||
(insert head)
|
||||
(insert (make-string (- align (length head)) ?\s))
|
||||
(insert (let ((r (file-relative-name path))
|
||||
(a (abbreviate-file-name path)))
|
||||
(if (< (string-width r) (string-width a)) r a)))
|
||||
(insert ?\n))))
|
||||
(align (1+ (apply #'max (--map (string-width (car it)) cols)))))
|
||||
(pcase-dolist (`(,head . ,config) cols)
|
||||
(magit--insert-worktree
|
||||
config
|
||||
(concat head (make-string (- align (length head)) ?\s)))))
|
||||
(insert ?\n)))))
|
||||
|
||||
(defun magit--insert-worktree (config head)
|
||||
"Insert worktree section for CONFIG.
|
||||
See `magit-list-worktrees' for the format of CONFIG. HEAD is
|
||||
a prettified reference or revision representing the worktree,
|
||||
with padding for alignment."
|
||||
;; #4926 Before changing the signature, inform @vermiculus.
|
||||
(let ((path (car config)))
|
||||
(magit-insert-section (worktree path)
|
||||
(insert head)
|
||||
(insert (let ((relative (file-relative-name path))
|
||||
(absolute (abbreviate-file-name path)))
|
||||
(if (or (> (string-width relative) (string-width absolute))
|
||||
(equal relative "./"))
|
||||
absolute
|
||||
relative)))
|
||||
(insert ?\n))))
|
||||
|
||||
;;; _
|
||||
(provide 'magit-worktree)
|
||||
;;; magit-worktree.el ends here
|
||||
|
||||
Reference in New Issue
Block a user