diff options
| author | Jonas Bernoulli <jonas@bernoul.li> | 2020-12-24 11:17:09 +0100 |
|---|---|---|
| committer | Jonas Bernoulli <jonas@bernoul.li> | 2020-12-25 01:04:36 +0100 |
| commit | 3c4259e3e090d8575a6bcf80ad53a393bb16b05f (patch) | |
| tree | e57ebb202365fc7d64e004982b6e9b801cd383f2 | |
| parent | ab0e0b80abcc01ca041321d1ffd2b9c0d83e2465 (diff) | |
Improve push confirmation before setting and pushing
We only intended to require confirmation when setting the value
before pushing, but in one case the same code path is used when
the value is already set.
| -rw-r--r-- | lisp/magit-push.el | 11 | ||||
| -rw-r--r-- | lisp/magit-remote.el | 6 |
2 files changed, 10 insertions, 7 deletions
diff --git a/lisp/magit-push.el b/lisp/magit-push.el index c307f2a..68ca312 100644 --- a/lisp/magit-push.el +++ b/lisp/magit-push.el @@ -87,11 +87,12 @@ argument the push-remote can be changed before pushed to it." :if 'magit-get-current-branch :description 'magit-push--pushbranch-description (interactive (list (magit-push-arguments))) - (pcase-let ((`(,branch ,remote) + (pcase-let ((`(,branch ,remote ,changed) (magit--select-push-remote "push there"))) - (magit-confirm 'set-and-push - (format "Really use %S as push-remote and push %S there" - remote branch)) + (when changed + (magit-confirm 'set-and-push + (format "Really use \"%s\" as push-remote and push \"%s\" there" + remote branch))) (run-hooks 'magit-credential-hook) (magit-run-git-async "push" "-v" args remote (format "refs/heads/%s:refs/heads/%s" @@ -150,7 +151,7 @@ the upstream." ;; is what the user wants to happen. (setq merge (concat "refs/heads/" merge))) (magit-confirm 'set-and-push - (format "Really use %S as upstream and push %S there" + (format "Really use \"%s\" as upstream and push \"%s\" there" upstream branch))) (cl-pushnew "--set-upstream" args :test #'equal)) (run-hooks 'magit-credential-hook) diff --git a/lisp/magit-remote.el b/lisp/magit-remote.el index 5d2bf80..1bc5e0e 100644 --- a/lisp/magit-remote.el +++ b/lisp/magit-remote.el @@ -332,16 +332,18 @@ Delete the symbolic-ref \"refs/remotes/<remote>/HEAD\"." (defun magit--select-push-remote (prompt-suffix) (let* ((branch (or (magit-get-current-branch) (user-error "No branch is checked out"))) - (remote (magit-get-push-remote branch))) + (remote (magit-get-push-remote branch)) + (changed nil)) (when (or current-prefix-arg (not remote) (not (member remote (magit-list-remotes)))) + (setq changed t) (setq remote (magit-read-remote (format "Set %s and %s" (magit--push-remote-variable) prompt-suffix))) (setf (magit-get (magit--push-remote-variable branch)) remote)) - (list branch remote))) + (list branch remote changed))) ;;; _ (provide 'magit-remote) |
