diff options
| author | Kyle Meyer <kyle@kyleam.com> | 2022-08-06 03:02:54 -0400 |
|---|---|---|
| committer | Kyle Meyer <kyle@kyleam.com> | 2022-08-06 03:02:54 -0400 |
| commit | 8a0cc83eff98489d3685b8585afdcebbb47c1393 (patch) | |
| tree | 75e9115399fda94e938710004530d2625dea22ed /lisp/magit-push.el | |
| parent | 64cca91341f77c46dd3e6a1f694af36427b4ace7 (diff) | |
magit-push-implicitly--desc: Account for local upstream
The magit-push-implicitly--desc rewrite in the last commit doesn't
handle a local upstream such as
branch.topic.remote=.
branch.topic.merge=refs/heads/master
The problem is that it uses Git's fallback logic to determine the
remote when magit-get-remote returns nil, but magit-get-remote returns
nil when "branch.{branch}.remote" isn't set _or_ is set to ".". For
the "." case, the description incorrectly reports that the push will
be to the fallback remote rather than the local repo.
Fix this issue by side stepping magit-get-remote and treating "." as
any other remote. Showing "." as the remote seems accurate enough
given that the underlying push command will push to the local
repository, and it shows the "remote" as ".".
While touching this block of code, also pass the branch to
magit-get-push-remote so that it doesn't need to repeat the
magit-get-current-branch call itself.
Diffstat (limited to 'lisp/magit-push.el')
| -rw-r--r-- | lisp/magit-push.el | 20 |
1 files changed, 11 insertions, 9 deletions
diff --git a/lisp/magit-push.el b/lisp/magit-push.el index 900995d..179d0f5 100644 --- a/lisp/magit-push.el +++ b/lisp/magit-push.el @@ -300,15 +300,17 @@ what this command will do. To add it use something like: ;; so it doesn't make sense to talk about "pushing to upstream". ;; Depending on the options, you could end up pushing to the ;; "upstream" remote but not the "upstream" branch, and vice versa. - (let ((branch (magit-get-current-branch)) - (remote (or (magit-get-push-remote) - (magit-get-remote) - (let ((remotes (magit-list-remotes))) - (cond - ((and (magit-git-version>= "2.27") - (= (length remotes) 1)) - (car remotes)) - ((member "origin" remotes) "origin")))))) + (let* ((branch (magit-get-current-branch)) + (remote (or (magit-get-push-remote branch) + ;; Note: Avoid `magit-get-remote' because it + ;; filters out the local repo case ("."). + (magit-get "branch" branch "remote") + (let ((remotes (magit-list-remotes))) + (cond + ((and (magit-git-version>= "2.27") + (= (length remotes) 1)) + (car remotes)) + ((member "origin" remotes) "origin")))))) (if (null remote) "nothing (no remote)" (let ((refspec (magit-get "remote" remote "push"))) |
