Commit 8331e3e9 authored by Jonas Bernoulli's avatar Jonas Bernoulli

magit-push: provide better default target

* When pushing a branch, then offer the push-branch as default.  Only
  if that is not set, offer the upstream as before.
* When pushing a commit and it is reachable from HEAD, then offer to
  push to the push-remote of the current branch, or if that is not set,
  its upstream.  Closes #2820.
parent dd483ee5
......@@ -559,9 +559,15 @@ Both the source and the target are read in the minibuffer."
(interactive
(let ((source (magit-read-local-branch-or-commit "Push")))
(list source
(magit-read-remote-branch (format "Push %s to" source) nil
(magit-get-upstream-branch source)
source 'confirm)
(magit-read-remote-branch
(format "Push %s to" source) nil
(if (magit-local-branch-p source)
(or (magit-get-push-branch source)
(magit-get-upstream-branch source))
(and (magit-rev-ancestor-p source "HEAD")
(or (magit-get-push-branch)
(magit-get-upstream-branch))))
source 'confirm)
(magit-push-arguments))))
(magit-git-push source target args))
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment