Function: magit-read-upstream-branch
magit-read-upstream-branch is a byte-compiled function defined in
magit-git.el.
Signature
(magit-read-upstream-branch &optional BRANCH PROMPT)
Documentation
Read the upstream for BRANCH using PROMPT.
If optional BRANCH is nil, then read the upstream for the current branch, or raise an error if no branch is checked out. Only existing branches can be selected.
Source Code
;; Defined in ~/.emacs.d/elpa/magit-20260411.1452/magit-git.el
(defun magit-read-upstream-branch (&optional branch prompt)
"Read the upstream for BRANCH using PROMPT.
If optional BRANCH is nil, then read the upstream for the
current branch, or raise an error if no branch is checked
out. Only existing branches can be selected."
(unless branch
(setq branch (or (magit-get-current-branch)
(error "Need a branch to set its upstream"))))
(let ((branches (delete branch (magit-list-branch-names))))
(magit-completing-read
(or prompt (format "Change upstream of %s to" branch))
branches nil t nil 'magit-revision-history
(or (let ((r (car (member (magit-remote-branch-at-point) branches)))
(l (car (member (magit-local-branch-at-point) branches))))
(if magit-prefer-remote-upstream (or r l) (or l r)))
(and-let ((main (magit-main-branch)))
(let ((r (car (member (concat "origin/" main) branches)))
(l (car (member main branches))))
(if magit-prefer-remote-upstream (or r l) (or l r))))
(car (member (magit-get-previous-branch) branches))))))