Function: vc-git-incoming-revision

vc-git-incoming-revision is a byte-compiled function defined in vc-git.el.gz.

Signature

(vc-git-incoming-revision &optional UPSTREAM-LOCATION REFRESH)

Source Code

;; Defined in /usr/src/emacs/lisp/vc/vc-git.el.gz
(defun vc-git-incoming-revision (&optional upstream-location refresh)
  (let ((rev (or upstream-location "@{upstream}")))
    (when (and (or refresh (null (vc-git--rev-parse rev)))
               ;; If the branch has no upstream, and we weren't supplied
               ;; with one, then fetching is always useless (bug#79952).
               (or upstream-location
                   (and-let* ((branch (vc-git--current-branch)))
                     (with-temp-buffer
                       (vc-git--out-ok "config" "--get"
                                       (format "branch.%s.remote"
                                               branch))))))
      (vc-git-command nil 0 nil "fetch"
                      (and upstream-location
                           ;; Extract remote from "remote/branch".
                           (replace-regexp-in-string "/.*" ""
                                                     upstream-location))))
    (ignore-errors            ; in order to return nil if no such branch
      (with-output-to-string
        (vc-git-command standard-output 0 nil
                        "log" "--max-count=1" "--pretty=format:%H" rev)))))