Commit 518bd3a6 authored by Jonas Bernoulli's avatar Jonas Bernoulli

magit-clone-set-branch.pushDefault: new option

parent 45c23052
......@@ -58,6 +58,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 option `magit-clone-set-branch.pushDefault' was added. #2447
* The command `magit-push-implicitly', Magit's equivalent of `git
push', was removed. #2414
......
......@@ -2457,6 +2457,13 @@ 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
Whether to set the value of ~branch.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.
** Staging and unstaging
Like Git, Magit can of course stage and unstage complete files.
......
......@@ -3399,8 +3399,17 @@ This command clones a repository and then shows the status buffer
for the new repository.
The user is queried for a remote url and a local directory.
@end table
@defopt magit-clone-set-branch.pushDefault
Whether to set the value of @code{branch.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.
@end defopt
@node Staging and unstaging
@section Staging and unstaging
......
......@@ -33,6 +33,17 @@
;;; Clone
(defcustom magit-clone-set-branch.pushDefault 'ask
"Whether to set the value of `branch.pushDefault' after cloning.
If t, then set without asking. If nil, then don't set. If
`ask', then ask."
:package-version '(magit . "2.4.0")
:group 'magit-commands
:type '(choice (const "set" t)
(const "ask" ask)
(const "don't set" nil)))
;;;###autoload
(defun magit-clone (repository directory)
"Clone the REPOSITORY to DIRECTORY.
......@@ -49,6 +60,10 @@ 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"))
(message "Cloning %s...done" repository)
(magit-status-internal directory)))
......
......@@ -1359,8 +1359,8 @@ of the new branch, instead of the starting-point itself."
(-if-let (current (magit-get-current-branch))
(let (tracked base)
(magit-call-git "checkout" args "-b" branch current)
(-when-let (indirect (magit-get-indirect-upstream-branch current))
(magit-call-git "branch" "--set-upstream-to" indirect branch))
(--when-let (magit-get-indirect-upstream-branch current)
(magit-call-git "branch" "--set-upstream-to" it branch))
(when (and (setq tracked (magit-get-upstream-branch current))
(setq base (magit-git-string "merge-base" current tracked))
(not (magit-rev-equal base current)))
......
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