Function: magit-insert-remote-branches
magit-insert-remote-branches is a byte-compiled function defined in
magit-refs.el.
Signature
(magit-insert-remote-branches)
Documentation
Insert sections showing all remote-tracking branches.
Source Code
;; Defined in ~/.emacs.d/elpa/magit-20260411.1452/magit-refs.el
(defun magit-insert-remote-branches ()
"Insert sections showing all remote-tracking branches."
(dolist (remote (magit-list-remotes))
(magit-insert-section (remote remote)
(magit-insert-heading
(let ((pull (magit-get "remote" remote "url"))
(push (magit-get "remote" remote "pushurl")))
(format (propertize "Remote %s (%s):"
'font-lock-face 'magit-section-heading)
(propertize remote 'font-lock-face 'magit-branch-remote)
(concat pull (and pull push ", ") push))))
(let (head)
(dolist (line (magit-git-lines "for-each-ref" "--format=\
%(symref:short)%00%(refname:short)%00%(refname)%00%(subject)"
(concat "refs/remotes/" remote)
magit-buffer-refs-args))
(pcase-let ((`(,head-branch ,branch ,ref ,msg)
(cl-substitute nil ""
(split-string line "\0")
:test #'equal)))
(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))
(abbrev (if magit-refs-show-remote-prefix
branch
(substring branch (1+ (length remote))))))
(magit-insert-heading
(magit-refs--format-focus-column branch)
(magit-refs--propertize-branch
abbrev ref (and headp 'magit-branch-remote-head))
(make-string
(max 1 (- (if (consp magit-refs-primary-column-width)
(car magit-refs-primary-column-width)
magit-refs-primary-column-width)
(length abbrev)))
?\s)
(and msg (magit-log--wash-summary msg))))
(magit-refs--maybe-format-margin branch)
(magit-refs--insert-cherry-commits branch))))))))
(insert ?\n)
(magit-make-margin-overlay))))