update packages
This commit is contained in:
@@ -1,9 +1,9 @@
|
||||
;;; magit-refs.el --- Listing references -*- lexical-binding:t -*-
|
||||
|
||||
;; Copyright (C) 2008-2023 The Magit Project Contributors
|
||||
;; Copyright (C) 2008-2025 The Magit Project Contributors
|
||||
|
||||
;; Author: Jonas Bernoulli <jonas@bernoul.li>
|
||||
;; Maintainer: Jonas Bernoulli <jonas@bernoul.li>
|
||||
;; Author: Jonas Bernoulli <emacs.magit@jonas.bernoulli.dev>
|
||||
;; Maintainer: Jonas Bernoulli <emacs.magit@jonas.bernoulli.dev>
|
||||
|
||||
;; SPDX-License-Identifier: GPL-3.0-or-later
|
||||
|
||||
@@ -42,11 +42,11 @@
|
||||
:type 'hook)
|
||||
|
||||
(defcustom magit-refs-sections-hook
|
||||
'(magit-insert-error-header
|
||||
magit-insert-branch-description
|
||||
magit-insert-local-branches
|
||||
magit-insert-remote-branches
|
||||
magit-insert-tags)
|
||||
(list #'magit-insert-error-header
|
||||
#'magit-insert-branch-description
|
||||
#'magit-insert-local-branches
|
||||
#'magit-insert-remote-branches
|
||||
#'magit-insert-tags)
|
||||
"Hook run to insert sections into a references buffer."
|
||||
:package-version '(magit . "2.1.0")
|
||||
:group 'magit-refs
|
||||
@@ -100,6 +100,15 @@ in the heading preceding the list of its branches."
|
||||
:group 'magit-refs
|
||||
:type 'boolean)
|
||||
|
||||
(defcustom magit-refs-show-branch-descriptions nil
|
||||
"Whether to show the description, if any, of local branches.
|
||||
To distinguish branch descriptions from the commit summary of the tip,
|
||||
which is shown when there is no description or this option is disabled,
|
||||
descriptions use the bold face."
|
||||
:package-version '(magit . "4.3.0")
|
||||
:group 'magit-refs
|
||||
:type 'boolean)
|
||||
|
||||
(defcustom magit-refs-margin
|
||||
(list nil
|
||||
(nth 1 magit-log-margin)
|
||||
@@ -141,7 +150,7 @@ tags."
|
||||
:group 'magit-margin
|
||||
:type 'boolean)
|
||||
|
||||
(defcustom magit-refs-primary-column-width (cons 16 32)
|
||||
(defcustom magit-refs-primary-column-width '(16 . 32)
|
||||
"Width of the focus column in `magit-refs-mode' buffers.
|
||||
|
||||
The primary column is the column that contains the name of the
|
||||
@@ -238,7 +247,7 @@ the outcome.
|
||||
and lists of cherry commits relative to the reference at point
|
||||
instead of relative to the current buffer or `HEAD'.
|
||||
|
||||
Instead of adding this symbol, consider pressing \"C-u y o RET\".
|
||||
Instead of adding this symbol, consider pressing \\`C-u y o RET'.
|
||||
|
||||
`create-branch'
|
||||
|
||||
@@ -294,8 +303,9 @@ Type \\[magit-cherry-pick] to apply the commit at point.
|
||||
Type \\[magit-reset] to reset `HEAD' to the commit at point.
|
||||
|
||||
\\{magit-refs-mode-map}"
|
||||
:interactive nil
|
||||
:group 'magit-refs
|
||||
(hack-dir-local-variables-non-file-buffer)
|
||||
(magit-hack-dir-local-variables)
|
||||
(setq magit--imenu-group-types '(local remote tags)))
|
||||
|
||||
(defun magit-refs-setup-buffer (ref args)
|
||||
@@ -309,7 +319,7 @@ Type \\[magit-reset] to reset `HEAD' to the commit at point.
|
||||
(setq magit-refs-show-commit-count nil))
|
||||
(magit-set-header-line-format
|
||||
(format "%s %s" magit-buffer-upstream
|
||||
(mapconcat #'identity magit-buffer-arguments " ")))
|
||||
(string-join magit-buffer-arguments " ")))
|
||||
(magit-insert-section (branchbuf)
|
||||
(magit-run-section-hook 'magit-refs-sections-hook))
|
||||
(add-hook 'kill-buffer-hook #'magit-preserve-section-visibility-cache))
|
||||
@@ -357,7 +367,7 @@ Type \\[magit-reset] to reset `HEAD' to the commit at point.
|
||||
(and-let* ((buffer (magit-get-mode-buffer
|
||||
'magit-refs-mode nil
|
||||
(eq use-buffer-args 'selected))))
|
||||
(progn ; work around debbugs#31840
|
||||
(progn
|
||||
(setq args (buffer-local-value 'magit-buffer-arguments buffer))
|
||||
t))))
|
||||
(t
|
||||
@@ -406,8 +416,12 @@ Compared with a branch read from the user."
|
||||
(magit-show-refs-arguments)))
|
||||
(magit-refs-setup-buffer ref args))
|
||||
|
||||
(defun magit-refs-set-show-commit-count ()
|
||||
(transient-define-suffix magit-refs-set-show-commit-count ()
|
||||
"Change for which refs the commit count is shown."
|
||||
:description "Change verbosity"
|
||||
:key "v"
|
||||
:transient nil
|
||||
:if-derived 'magit-refs-mode
|
||||
(interactive)
|
||||
(setq-local magit-refs-show-commit-count
|
||||
(magit-read-char-case "Show commit counts for " nil
|
||||
@@ -523,7 +537,7 @@ line is inserted at all."
|
||||
(magit-insert-section (branchdesc branch t)
|
||||
(magit-insert-heading branch ": " (car desc))
|
||||
(when (cdr desc)
|
||||
(insert (mapconcat #'identity (cdr desc) "\n"))
|
||||
(insert (string-join (cdr desc) "\n"))
|
||||
(insert "\n\n")))))
|
||||
|
||||
(defun magit-insert-tags ()
|
||||
@@ -531,7 +545,7 @@ line is inserted at all."
|
||||
(when-let ((tags (magit-git-lines "tag" "--list" "-n" magit-buffer-arguments)))
|
||||
(let ((_head (magit-rev-parse "HEAD")))
|
||||
(magit-insert-section (tags)
|
||||
(magit-insert-heading "Tags:")
|
||||
(magit-insert-heading (length tags) "Tags")
|
||||
(dolist (tag tags)
|
||||
(string-match "^\\([^ \t]+\\)[ \t]+\\([^ \t\n].*\\)?" tag)
|
||||
(let ((tag (match-string 1 tag))
|
||||
@@ -547,7 +561,7 @@ line is inserted at all."
|
||||
magit-refs-primary-column-width)
|
||||
(length tag)))
|
||||
?\s)
|
||||
(and msg (magit-log-propertize-keywords nil msg)))
|
||||
(and msg (magit-log--wash-summary msg)))
|
||||
(when (and magit-refs-margin-for-tags (magit-buffer-margin-p))
|
||||
(magit-refs--format-margin tag))
|
||||
(magit-refs--insert-cherry-commits tag)))))
|
||||
@@ -574,14 +588,18 @@ line is inserted at all."
|
||||
(cl-substitute nil ""
|
||||
(split-string line "\0")
|
||||
:test #'equal)))
|
||||
(if head-branch
|
||||
;; Note: Use `ref' instead of `branch' for the check
|
||||
;; below because 'refname:short' shortens the remote
|
||||
;; HEAD to '<remote>' instead of '<remote>/HEAD' as of
|
||||
;; Git v2.40.0.
|
||||
(progn (cl-assert
|
||||
(equal ref (concat "refs/remotes/" remote "/HEAD")))
|
||||
(setq head head-branch))
|
||||
(cond
|
||||
(head-branch
|
||||
;; Note: Use `ref' instead of `branch' for the check
|
||||
;; below because 'refname:short' shortens the remote
|
||||
;; HEAD to '<remote>' instead of '<remote>/HEAD' as of
|
||||
;; Git v2.40.0.
|
||||
(cl-assert
|
||||
(equal ref (concat "refs/remotes/" remote "/HEAD")))
|
||||
(setq head head-branch))
|
||||
((not (equal ref (concat "refs/remotes/" remote "/HEAD")))
|
||||
;; ^ Skip mis-configured remotes where HEAD is not a
|
||||
;; symref. See #5092.
|
||||
(when (magit-refs--insert-refname-p branch)
|
||||
(magit-insert-section (branch branch t)
|
||||
(let ((headp (equal branch head))
|
||||
@@ -598,23 +616,23 @@ line is inserted at all."
|
||||
magit-refs-primary-column-width)
|
||||
(length abbrev)))
|
||||
?\s)
|
||||
(and msg (magit-log-propertize-keywords nil msg))))
|
||||
(and msg (magit-log--wash-summary msg))))
|
||||
(when (magit-buffer-margin-p)
|
||||
(magit-refs--format-margin branch))
|
||||
(magit-refs--insert-cherry-commits branch)))))))
|
||||
(magit-refs--insert-cherry-commits branch))))))))
|
||||
(insert ?\n)
|
||||
(magit-make-margin-overlay nil t))))
|
||||
|
||||
(defun magit-insert-local-branches ()
|
||||
"Insert sections showing all local branches."
|
||||
(magit-insert-section (local nil)
|
||||
(magit-insert-heading "Branches:")
|
||||
(magit-insert-heading t "Branches")
|
||||
(dolist (line (magit-refs--format-local-branches))
|
||||
(pcase-let ((`(,branch . ,strings) line))
|
||||
(magit-insert-section
|
||||
((eval (if branch 'branch 'commit))
|
||||
(or branch (magit-rev-parse "HEAD"))
|
||||
t)
|
||||
((eval (if branch 'branch 'commit))
|
||||
(or branch (magit-rev-parse "HEAD"))
|
||||
t)
|
||||
(apply #'magit-insert-heading strings)
|
||||
(when (magit-buffer-margin-p)
|
||||
(magit-refs--format-margin branch))
|
||||
@@ -631,7 +649,7 @@ line is inserted at all."
|
||||
%(upstream:short)%00%(upstream)%00%(upstream:track)%00"
|
||||
(if magit-refs-show-push-remote "\
|
||||
%(push:remotename)%00%(push)%00%(push:track)%00%(subject)"
|
||||
"%00%00%00%(subject)"))
|
||||
"%00%00%00%(subject)"))
|
||||
"refs/heads"
|
||||
magit-buffer-arguments))))
|
||||
(unless (magit-get-current-branch)
|
||||
@@ -644,8 +662,9 @@ line is inserted at all."
|
||||
def
|
||||
(pcase-let ((`(,min . ,max) def))
|
||||
(min max (apply #'max min (mapcar #'car lines)))))))
|
||||
(mapcar (pcase-lambda (`(,_ ,branch ,focus ,branch-desc ,u:ahead ,p:ahead
|
||||
,u:behind ,upstream ,p:behind ,push ,msg))
|
||||
(mapcar (pcase-lambda (`( ,_ ,branch ,focus
|
||||
,branch-desc ,u:ahead ,p:ahead
|
||||
,u:behind ,upstream ,p:behind ,msg))
|
||||
(list branch focus branch-desc u:ahead p:ahead
|
||||
(make-string (max 1 (- magit-refs-primary-column-width
|
||||
(length (concat branch-desc
|
||||
@@ -653,8 +672,7 @@ line is inserted at all."
|
||||
p:ahead
|
||||
u:behind))))
|
||||
?\s)
|
||||
u:behind upstream p:behind push
|
||||
msg))
|
||||
u:behind upstream p:behind msg))
|
||||
lines)))
|
||||
|
||||
(defun magit-refs--format-local-branch (line)
|
||||
@@ -668,7 +686,7 @@ line is inserted at all."
|
||||
magit-refs-show-push-remote
|
||||
(magit-rev-verify p:ref)
|
||||
(not (equal p:ref u:ref))))
|
||||
(branch-desc
|
||||
(branch-pretty
|
||||
(if branch
|
||||
(magit-refs--propertize-branch
|
||||
branch ref (and headp 'magit-branch-current))
|
||||
@@ -701,10 +719,11 @@ line is inserted at all."
|
||||
(match-string 1 p:track)
|
||||
(and magit-refs-pad-commit-counts " "))
|
||||
'magit-dimmed))))
|
||||
(list (1+ (length (concat branch-desc u:ahead p:ahead u:behind)))
|
||||
(list (1+ (length (concat branch-pretty u:ahead p:ahead u:behind)))
|
||||
branch
|
||||
(magit-refs--format-focus-column branch headp)
|
||||
branch-desc u:ahead p:ahead u:behind
|
||||
branch-pretty u:ahead p:ahead
|
||||
u:behind
|
||||
(and upstream
|
||||
(concat (if (equal u:track "[gone]")
|
||||
(magit--propertize-face upstream 'error)
|
||||
@@ -715,7 +734,10 @@ line is inserted at all."
|
||||
(magit--propertize-face
|
||||
push 'magit-branch-remote)
|
||||
" "))
|
||||
(and msg (magit-log-propertize-keywords nil msg)))))))
|
||||
(if-let ((magit-refs-show-branch-descriptions)
|
||||
(desc (magit-get "branch" branch "description")))
|
||||
(magit--propertize-face desc 'bold)
|
||||
(and msg (magit-log--wash-summary msg))))))))
|
||||
|
||||
(defun magit-refs--format-focus-column (ref &optional type)
|
||||
(let ((focus magit-buffer-upstream)
|
||||
|
||||
Reference in New Issue
Block a user