Fix strange logic in vc-git-incoming-revision

I think that I didn't fully update this function in this change:

    commit e915646b89
    Author: Sean Whitton <spwhitton@spwhitton.name>
    Date:   Wed Feb 18 11:35:16 2026 +0000

        vc-git-pull, vc-git-incoming-revision: Use push remotes

        * lisp/vc/vc-git.el (vc-git-pull, vc-git-incoming-revision): Use
        configured push remotes.
        * etc/NEWS: Announce change to vc-git-pull.

* lisp/vc/vc-git.el (vc-git-incoming-revision): Don't duplicate
looking for a branch remote after just having called
vc-git--branch-remotes (bug#81328).
This commit is contained in:
Sean Whitton 2026-06-29 11:51:41 +01:00
parent 10ae134ceb
commit 1ac2f60b53

View file

@ -1911,28 +1911,18 @@ If LIMIT is a non-empty string, use it as a base revision."
'("--")))))))
(defun vc-git-incoming-revision (&optional upstream-location refresh)
(let* ((remotes (and (not upstream-location) (vc-git--branch-remotes)))
(rev (or upstream-location
(cdr (assq 'push remotes))
(cdr (assq 'upstream remotes)))))
(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-working-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)))))
(let ((remotes (and (not upstream-location) (vc-git--branch-remotes))))
(and-let* ((rev (or upstream-location
(cdr (assq 'push remotes))
(cdr (assq 'upstream remotes)))))
(when (or refresh (null (vc-git--rev-parse rev)))
(vc-git-command nil 0 nil "fetch"
;; Extract remote from "remote/branch".
(replace-regexp-in-string "/.*" "" rev)))
(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))))))
(defun vc-git-log-search (buffer pattern)
"Search the log of changes for PATTERN and output results into BUFFER.