Commit 5333ac79 authored by Sean Whitton's avatar Sean Whitton Committed by Kyle Meyer

Add switch to toggle passing -f to `git remote add`

parent e8b382f0
......@@ -4,6 +4,12 @@ Magit v2.10.4 Release Notes (unreleased)
Changes since v2.10.3
---------------------
* The popup `magit-remote-popup' now exposes the `-f' switch for `git
remote add', which allows the user to control whether information
from the remote is fetched after the remote is added. The default
behavior is still to fetch after adding a remote (i.e., the switch
is enabled by default). #2997
Fixes since v2.10.3
-------------------
......
......@@ -104,6 +104,9 @@ variable isn't already set."
(magit-define-popup magit-remote-popup
"Popup console for remote commands."
:man-page "git-remote"
:default-arguments '("-f")
:switches '("Switches for add"
(?f "Fetch after add" "-f"))
:actions '((?a "Add" magit-remote-add)
(?r "Rename" magit-remote-rename)
(?k "Remove" magit-remote-remove)
......@@ -116,19 +119,20 @@ variable isn't already set."
url)))
;;;###autoload
(defun magit-remote-add (remote url)
(defun magit-remote-add (remote url &optional args)
"Add a remote named REMOTE and fetch it."
(interactive (list (magit-read-string-ns "Remote name")
(magit-read-url "Remote url")))
(magit-read-url "Remote url")
(magit-remote-arguments)))
(if (pcase (list magit-remote-add-set-remote.pushDefault
(magit-get "remote.pushDefault"))
(`(,(pred stringp) ,_) t)
((or `(ask ,_) `(ask-if-unset nil))
(y-or-n-p (format "Set `remote.pushDefault' to \"%s\"? " remote))))
(progn (magit-call-git "remote" "add" "-f" remote url)
(progn (magit-call-git "remote" "add" args remote url)
(setf (magit-get "remote.pushDefault") remote)
(magit-refresh))
(magit-run-git-async "remote" "add" "-f" remote url)))
(magit-run-git-async "remote" "add" args remote url)))
;;;###autoload
(defun magit-remote-rename (old new)
......
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