Function: magit-refs--format-local-branch

magit-refs--format-local-branch is a byte-compiled function defined in magit-refs.el.

Signature

(magit-refs--format-local-branch LINE)

Source Code

;; Defined in ~/.emacs.d/elpa/magit-20260411.1452/magit-refs.el
(defun magit-refs--format-local-branch (line)
  (pcase-let ((`(,head ,branch ,ref ,upstream ,u:ref ,u:track
                       ,push ,p:ref ,p:track ,msg)
               (cl-substitute nil "" (split-string line "\0") :test #'equal)))
    (when (or (not branch)
              (magit-refs--insert-refname-p branch))
      (let* ((headp (equal head "*"))
             (pushp (and push
                         magit-refs-show-push-remote
                         (magit-rev-verify p:ref)
                         (not (equal p:ref u:ref))))
             (branch-pretty
              (if branch
                  (magit-refs--propertize-branch
                   branch ref (and headp 'magit-branch-current))
                (magit--propertize-face "(detached)" 'magit-branch-warning)))
             (u:ahead  (and u:track
                            (string-match "ahead \\([0-9]+\\)" u:track)
                            (magit--propertize-face
                             (concat (and magit-refs-pad-commit-counts " ")
                                     (match-str 1 u:track)
                                     ">")
                             'magit-dimmed)))
             (u:behind (and u:track
                            (string-match "behind \\([0-9]+\\)" u:track)
                            (magit--propertize-face
                             (concat "<"
                                     (match-str 1 u:track)
                                     (and magit-refs-pad-commit-counts " "))
                             'magit-dimmed)))
             (p:ahead  (and pushp p:track
                            (string-match "ahead \\([0-9]+\\)" p:track)
                            (magit--propertize-face
                             (concat (match-str 1 p:track)
                                     ">"
                                     (and magit-refs-pad-commit-counts " "))
                             'magit-branch-remote)))
             (p:behind (and pushp p:track
                            (string-match "behind \\([0-9]+\\)" p:track)
                            (magit--propertize-face
                             (concat "<"
                                     (match-str 1 p:track)
                                     (and magit-refs-pad-commit-counts " "))
                             'magit-dimmed))))
        (list (1+ (length (concat branch-pretty u:ahead p:ahead u:behind)))
              branch
              (magit-refs--format-focus-column branch headp)
              branch-pretty u:ahead p:ahead
              u:behind
              (and upstream
                   (concat (if (equal u:track "[gone]")
                               (magit--propertize-face upstream 'error)
                             (magit-refs--propertize-branch upstream u:ref))
                           " "))
              (and pushp
                   (concat p:behind
                           (magit--propertize-face
                            push 'magit-branch-remote)
                           " "))
              (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))))))))