Commit 71cb1e33 authored by Jonas Bernoulli's avatar Jonas Bernoulli

my name is pushDefault, remote.pushDefault

parent b42fbbc6
......@@ -67,8 +67,8 @@ Changes since v2.3.0
* The option `magit-branch-prefer-remote-upstream' was added for users
who prefer to always use remote branches as upstreams. #2447
* The options `magit-clone-set-branch.pushDefault' and
`magit-remote-add-set-branch.pushDefault' were added. #2447
* The options `magit-clone-set-remote.pushDefault' and
`magit-remote-add-set-remote.pushDefault' were added. #2447
* When Git is run for side-effects and exits with a non-zero status,
then the respective error message is now inserted into the status
......
......@@ -2457,9 +2457,9 @@ Also see [[info:gitman#git-blame]].
The user is queried for a remote url and a local directory.
- User Option: magit-clone-set-branch.pushDefault
- User Option: magit-clone-set-remote.pushDefault
Whether to set the value of ~branch.pushDefault~ after cloning.
Whether to set the value of ~remote.pushDefault~ after cloning.
If ~t~, then set without asking. If ~nil~, then don't set. If ~ask~,
then ask the user every time she clones a repository.
......@@ -3818,9 +3818,9 @@ Also see [[info:gitman#git-remote]].
Delete a remote, read from the minibuffer.
- User Option: magit-remote-add-set-branch.pushDefault
- User Option: magit-remote-add-set-remote.pushDefault
Whether to set the value of ~branch.pushDefault~ after adding a
Whether to set the value of ~remote.pushDefault~ after adding a
remote.
If ~ask~, then always ask. If ~ask-if-unset~, then ask, but only if the
......@@ -3952,7 +3952,7 @@ them to the popup.
This command simply runs ~git push -v [ARGS]~. ARGS are the arguments
specified in the popup buffer. No explicit refspec arguments are
used. Instead the behavior depends on at least these Git variables:
~push.default~, ~branch.pushDefault~, ~branch.<branch>.pushRemote~,
~push.default~, ~remote.pushDefault~, ~branch.<branch>.pushRemote~,
~branch.<branch>.remote~, ~branch.<branch>.merge~, and
~remote.<remote>.push~.
......@@ -3964,7 +3964,7 @@ them to the popup.
This command simply runs ~git push -v [ARGS] REMOTE~. ARGS are the
arguments specified in the popup buffer. No refspec arguments are
used. Instead the behavior depends on at least these Git variables:
~push.default~, ~branch.pushDefault~, ~branch.<branch>.pushRemote~,
~push.default~, ~remote.pushDefault~, ~branch.<branch>.pushRemote~,
~branch.<branch>.remote~, ~branch.<branch>.merge~, and
~remote.<remote>.push~.
......
......@@ -3402,9 +3402,9 @@ The user is queried for a remote url and a local directory.
@end table
@defopt magit-clone-set-branch.pushDefault
@defopt magit-clone-set-remote.pushDefault
Whether to set the value of @code{branch.pushDefault} after cloning.
Whether to set the value of @code{remote.pushDefault} after cloning.
If @code{t}, then set without asking. If @code{nil}, then don't set. If @code{ask},
then ask the user every time she clones a repository.
......@@ -5336,9 +5336,9 @@ Delete a remote, read from the minibuffer.
@end table
@defopt magit-remote-add-set-branch.pushDefault
@defopt magit-remote-add-set-remote.pushDefault
Whether to set the value of @code{branch.pushDefault} after adding a
Whether to set the value of @code{remote.pushDefault} after adding a
remote.
If @code{ask}, then always ask. If @code{ask-if-unset}, then ask, but only if the
......@@ -5553,7 +5553,7 @@ Push somewhere without using an explicit refspec.
This command simply runs @code{git push -v [ARGS]}. ARGS are the arguments
specified in the popup buffer. No explicit refspec arguments are
used. Instead the behavior depends on at least these Git variables:
@code{push.default}, @code{branch.pushDefault}, @code{branch.<branch>.pushRemote},
@code{push.default}, @code{remote.pushDefault}, @code{branch.<branch>.pushRemote},
@code{branch.<branch>.remote}, @code{branch.<branch>.merge}, and
@code{remote.<remote>.push}.
@end deffn
......@@ -5567,7 +5567,7 @@ remote is read in the minibuffer.
This command simply runs @code{git push -v [ARGS] REMOTE}. ARGS are the
arguments specified in the popup buffer. No refspec arguments are
used. Instead the behavior depends on at least these Git variables:
@code{push.default}, @code{branch.pushDefault}, @code{branch.<branch>.pushRemote},
@code{push.default}, @code{remote.pushDefault}, @code{branch.<branch>.pushRemote},
@code{branch.<branch>.remote}, @code{branch.<branch>.merge}, and
@code{remote.<remote>.push}.
@end deffn
......
......@@ -33,8 +33,8 @@
;;; Clone
(defcustom magit-clone-set-branch.pushDefault 'ask
"Whether to set the value of `branch.pushDefault' after cloning.
(defcustom magit-clone-set-remote.pushDefault 'ask
"Whether to set the value of `remote.pushDefault' after cloning.
If t, then set without asking. If nil, then don't set. If
`ask', then ask."
......@@ -60,17 +60,17 @@ Then show the status buffer for the new repository."
;; Stop cygwin git making a "c:" directory.
(magit-convert-git-filename directory))
0)
(when (or (eq magit-clone-set-branch.pushDefault t)
(and magit-clone-set-branch.pushDefault
(y-or-n-p "Set `branch.pushDefault' to \"origin\"? ")))
(magit-call-git "config" "branch.pushDefault" "origin"))
(when (or (eq magit-clone-set-remote.pushDefault t)
(and magit-clone-set-remote.pushDefault
(y-or-n-p "Set `remote.pushDefault' to \"origin\"? ")))
(magit-call-git "config" "remote.pushDefault" "origin"))
(message "Cloning %s...done" repository)
(magit-status-internal directory)))
;;; Setup
(defcustom magit-remote-add-set-branch.pushDefault 'ask-if-unset
"Whether to set the value of `branch.pushDefault' after adding a remote.
(defcustom magit-remote-add-set-remote.pushDefault 'ask-if-unset
"Whether to set the value of `remote.pushDefault' after adding a remote.
If `ask', then always ask. If `ask-if-unset', then ask, but only
if the variable isn't set already. If nil, then don't ever set.
......@@ -105,13 +105,13 @@ the variable isn't already set."
"Add a remote named REMOTE and fetch it."
(interactive (list (magit-read-string-ns "Remote name")
(magit-read-url "Remote url")))
(if (pcase (list magit-remote-add-set-branch.pushDefault
(magit-get "branch.defaultPush"))
(if (pcase (list magit-remote-add-set-remote.pushDefault
(magit-get "remote.defaultPush"))
(`(,(pred stringp) ,_) t)
((or `(ask ,_) `(ask-if-unset nil))
(y-or-n-p (format "Set `branch.pushDefault' to \"%s\"? " remote))))
(y-or-n-p (format "Set `remote.pushDefault' to \"%s\"? " remote))))
(progn (magit-call-git "remote" "add" "-f" remote url)
(magit-call-git "config" "branch.pushDefault" remote)
(magit-call-git "config" "remote.pushDefault" remote)
(magit-refresh))
(magit-run-git-async "remote" "add" "-f" remote url)))
......@@ -528,7 +528,7 @@ branch as default."
This command simply runs \"git push -v [ARGS]\". ARGS are the
arguments specified in the popup buffer. No explicit refspec
arguments are used. Instead the behavior depends on at least
these Git variables: `push.default', `branch.pushDefault',
these Git variables: `push.default', `remote.pushDefault',
`branch.<branch>.pushRemote', `branch.<branch>.remote',
`branch.<branch>.merge', and `remote.<remote>.push'.
......@@ -581,7 +581,7 @@ The REMOTE is read in the minibuffer.
This command simply runs \"git push -v [ARGS] REMOTE\". ARGS
are the arguments specified in the popup buffer. No refspec
arguments are used. Instead the behavior depends on at least
these Git variables: `push.default', `branch.pushDefault',
these Git variables: `push.default', `remote.pushDefault',
`branch.<branch>.pushRemote', `branch.<branch>.remote',
`branch.<branch>.merge', and `remote.<remote>.push'.
......
......@@ -1084,10 +1084,13 @@ Add FUNCTION at the beginning of the hook list unless optional
APPEND is non-nil, in which case FUNCTION is added at the end.
If FUNCTION already is a member then move it to the new location.
If optional AT is non-nil and a member of the hook list, then add
FUNCTION next to that instead. Add before or after AT depending
on APPEND. If only FUNCTION is a member of the list, then leave
it where ever it already is.
If optional AT is non-nil and a member of the hook list, then
add FUNCTION next to that instead. Add before or after AT, or
replace AT with FUNCTION depending on APPEND. If APPEND is the
symbol `replace', then replace AT with FUNCTION. For any other
non-nil value place FUNCTION right after AT. If nil, then place
FUNCTION right before AT. If FUNCTION already is a member of the
list but AT is not, then leave FUNCTION where ever it already is.
If optional LOCAL is non-nil, then modify the hook's buffer-local
value rather than its global value. This makes the hook local by
......@@ -1122,6 +1125,8 @@ again use `remove-hook'."
(setq value (if append
(append value (list function))
(cons function value))))
(when (eq append 'replace)
(setq value (delq at value)))
(if local
(set hook value)
(set-default hook value))))
......
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