Function: magit-get-tracked

magit-get-tracked is a byte-compiled function defined in magit-git.el.

Signature

(magit-get-tracked REFNAME)

Documentation

Return the remote branch tracked by the remote-tracking branch REFNAME.

The returned value has the form (REMOTE . REF), where REMOTE is the name of a remote and REF is the ref local to the remote.

Source Code

;; Defined in ~/.emacs.d/elpa/magit-20260411.1452/magit-git.el
(defun magit-get-tracked (refname)
  "Return the remote branch tracked by the remote-tracking branch REFNAME.
The returned value has the form (REMOTE . REF), where REMOTE is
the name of a remote and REF is the ref local to the remote."
  (and-let ((ref (magit-ref-fullname refname)))
    (save-match-data
      (seq-some (lambda (line)
                  (and (string-match "\
\\`remote\\.\\([^.]+\\)\\.fetch=\\+?\\([^:]+\\):\\(.+\\)" line)
                       (let ((rmt (match-str 1 line))
                             (src (match-str 2 line))
                             (dst (match-str 3 line)))
                         (and (string-match (format "\\`%s\\'"
                                                    (string-replace
                                                     "*" "\\(.+\\)" dst))
                                            ref)
                              (cons rmt (string-replace
                                         "*" (match-str 1 ref) src))))))
                (magit-git-lines "config" "--local" "--list")))))