Function: vc-git--branch-remotes
vc-git--branch-remotes is a byte-compiled function defined in
vc-git.el.gz.
Signature
(vc-git--branch-remotes &optional BRANCH)
Documentation
Return alist of configured remote branches for BRANCH.
BRANCH defaults to the current branch.
If there is a configured upstream, return the remote-tracking branch
with key upstream. If there is a distinct configured push remote,
return the remote-tracking branch there with key push.
A configured push remote that's just the same as the upstream remote is
ignored because that means we're not actually in a triangular workflow.
Source Code
;; Defined in /usr/src/emacs/lisp/vc/vc-git.el.gz
(defun vc-git--branch-remotes (&optional branch)
"Return alist of configured remote branches for BRANCH.
BRANCH defaults to the current branch.
If there is a configured upstream, return the remote-tracking branch
with key `upstream'. If there is a distinct configured push remote,
return the remote-tracking branch there with key `push'.
A configured push remote that's just the same as the upstream remote is
ignored because that means we're not actually in a triangular workflow."
;; Possibly we could simplify this using @{push}, but that may involve
;; an unwanted dependency on the setting of push.default.
(cl-flet ((get (key)
(string-trim-right (vc-git--out-str "config" key))))
(let* ((branch (or branch (vc-git-working-branch)))
(pull (get (format "branch.%s.remote" branch)))
(merge (string-remove-prefix "refs/heads/"
(get (format "branch.%s.merge"
branch))))
(push (get (format "branch.%s.pushRemote" branch)))
(push (if (string-empty-p push)
(get "remote.pushDefault")
push))
(alist (and (not (string-empty-p pull))
(not (string-empty-p merge))
`((upstream . ,(format "%s/%s" pull merge))))))
(if (or (string-empty-p push) (equal push pull))
alist
(cl-acons 'push (format "%s/%s" push branch) alist)))))