Commit c1fea95a authored by Jonas Bernoulli's avatar Jonas Bernoulli

magit-read-upstream-branch: new function

parent b2ef8f19
......@@ -1244,6 +1244,21 @@ Return a list of two integers: (A>B B>A)."
nil nil nil 'magit-revision-history default)
(user-error "Nothing selected"))))
(cl-defun magit-read-upstream-branch
(&optional (branch (magit-get-current-branch)) prompt)
(magit-completing-read (or prompt (format "Change upstream of %s to" branch))
(nconc (--map (concat it "/" branch)
(delete branch (magit-list-branch-names)))
nil nil nil 'magit-revision-history
(or (let ((atpoint (magit-branch-at-point)))
(and (not (equal atpoint branch)) atpoint))
(magit-branch-p "origin/master")
(and (not (equal branch "master"))
(magit-branch-p "master"))
(let ((previous (magit-get-previous-branch)))
(and (not (equal previous branch)) previous)))))
(defun magit-read-tag (prompt &optional require-match)
(magit-completing-read prompt (magit-list-tags) nil
require-match nil 'magit-revision-history
......@@ -436,13 +436,7 @@ upstream can be changed before pushed to it."
(list (magit-push-arguments)
(and (magit--push-current-set-upstream-p current-prefix-arg)
(let ((branch (magit-get-current-branch)))
(format "Set upstream of %s and push there" branch)
nil (or (magit-branch-p "origin/master")
(and (not (equal branch "master"))
(magit-branch-p "master")))
(--if-let (magit-get-current-branch)
(when upstream
......@@ -1555,12 +1555,7 @@ already set. When nil, then always unset."
(magit-read-local-branch "Change upstream of branch"))))
(list branch (and (not (magit-get-upstream-branch branch))
(format "Change upstream of %s to" branch)
nil (or (magit-branch-p "origin/master")
(and (not (equal branch "master"))
(magit-branch-p "master")))
(if upstream
(-let (((remote . merge) (magit-split-branch-name upstream))
(branch (magit-get-current-branch)))
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