diff options
| author | Jonas Bernoulli <jonas@bernoul.li> | 2019-03-29 16:01:00 +0100 |
|---|---|---|
| committer | Jonas Bernoulli <jonas@bernoul.li> | 2019-03-29 16:01:00 +0100 |
| commit | fef5ab8b0821db96ef9995a5520e711b08754394 (patch) | |
| tree | 68eae008c0848e0b680a74d9fceead5317e3b508 /lisp/magit-remote.el | |
| parent | b2a7106b82455d7f571d483149d08592a85a8cc6 (diff) | |
Favor upstreams that can be resolved to a branch
Most callers of `magit-get-upstream-branch' only care about the
upstream if it can be resolved to a branch, but until now this
function defaulted to return some representation of the upstream
even when that is not possible.
The optional VERIFY argument was added to let callers declare that
they are only interested in resolved upstreams, but most callers
that should have been adjusted to use that argument were not.
This commit removes the VERIFY argument and replaces it with a LAX
argument, which has the opposite effect. By default this function
now returns the resolved upstream or nil.
Additionally this function is changed to use "git rev-parse --verify
--symbolic-full-name BRANCH@{upstream}" to determine the resolved
upstream. Previously it accessed the variables "branch.<name>.remote"
and "branch.<name>.merge" and then tried to resolve that to a local or
remote-tracking branch itself. The old approach resulted in incorrect
results in some edge cases.
The LAX argument is for callers such as the "push to the configured
upstream even if that doesn't exist yet" command, which cares about
configured but unsolvable upstreams. These commands need further
work, but that will be done in other commits. When LAX is non-nil,
then this function behaves exactly as it used to behave when VERIFY
was nil, including the bugs.
`magit-get-upstream-ref' now always returns the fully qualified and
resolved upstream or nil.
Diffstat (limited to 'lisp/magit-remote.el')
| -rw-r--r-- | lisp/magit-remote.el | 8 |
1 files changed, 4 insertions, 4 deletions
diff --git a/lisp/magit-remote.el b/lisp/magit-remote.el index cbf21f7..b90fba5 100644 --- a/lisp/magit-remote.el +++ b/lisp/magit-remote.el @@ -394,7 +394,7 @@ Delete the symbolic-ref \"refs/remotes/<remote>/HEAD\"." (progn (when upstream (magit-set-upstream-branch current upstream)) - (if-let ((upstream (or upstream (magit-get-upstream-branch current)))) + (if-let ((upstream (or upstream (magit-get-upstream-branch current t)))) (funcall fn current upstream) (user-error "No upstream is configured for %s" current))) (user-error "No branch is checked out"))) @@ -403,7 +403,7 @@ Delete the symbolic-ref \"refs/remotes/<remote>/HEAD\"." (when-let ((current (magit-get-current-branch))) (or change (and magit-remote-set-if-missing - (not (magit-get-upstream-branch current)))))) + (not (magit-get-upstream-branch current t)))))) (defun magit--transfer-maybe-read-upstream (action) (and (magit--transfer-set-upstream-p current-prefix-arg) @@ -412,11 +412,11 @@ Delete the symbolic-ref \"refs/remotes/<remote>/HEAD\"." (defun magit--upstream-suffix-predicate () (when-let ((current (magit-get-current-branch))) - (or (magit-get-upstream-branch current) + (or (magit-get-upstream-branch current t) magit-remote-set-if-missing))) (defun magit--upstream-suffix-description (&optional pushp) - (if-let ((upstream (magit-get-upstream-branch))) + (if-let ((upstream (magit-get-upstream-branch nil t))) (cond ((consp upstream) (pcase-let ((`(,url ,ref) upstream)) (insert ref " from " (propertize url 'face 'bold) " "))) |
