[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[nongnu] elpa/git-commit 8a0cc83eff 2/2: magit-push-implicitly--desc: Ac
From: |
ELPA Syncer |
Subject: |
[nongnu] elpa/git-commit 8a0cc83eff 2/2: magit-push-implicitly--desc: Account for local upstream |
Date: |
Sat, 6 Aug 2022 03:58:31 -0400 (EDT) |
branch: elpa/git-commit
commit 8a0cc83eff98489d3685b8585afdcebbb47c1393
Author: Kyle Meyer <kyle@kyleam.com>
Commit: Kyle Meyer <kyle@kyleam.com>
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.
---
lisp/magit-push.el | 20 +++++++++++---------
1 file changed, 11 insertions(+), 9 deletions(-)
diff --git a/lisp/magit-push.el b/lisp/magit-push.el
index 900995df18..179d0f5fb4 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")))