Commit cf479b9c authored by Noam Postavsky's avatar Noam Postavsky

magit-clone: run asynchronously

This allows intercepting password prompts, and is also nicer if the
clone happens to take a long time.
parent d9dde275
......@@ -34,6 +34,9 @@ Changes since v2.6.2
* Added new section inserter `magit-insert-worktrees'
* The command `magit-clone' now runs asynchronously, which avoid
blocking Emacs and allows handling password prompts.
* The command `magit-stage' learned to stage an untracked file while
leaving its content unstaged (i.e. `git add --intent-to-add') when
called with a prefix argument.
......@@ -61,20 +61,21 @@ Then show the status buffer for the new repository."
(and (string-match "\\([^./]+\\)\\(\\.git\\)?$" url)
(match-string 1 url))))))
(setq directory (file-name-as-directory (expand-file-name directory)))
(message "Cloning %s..." repository)
(when (= (magit-call-git "clone" repository
;; Stop cygwin git making a "c:" directory.
(magit-convert-git-filename directory))
(let ((default-directory directory))
(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"))
(unless magit-clone-set-remote-head
(magit-remote-unset-head "origin")))
(message "Cloning %s...done" repository)
(magit-status-internal directory)))
(magit-run-git-async "clone" repository
;; Stop cygwin git making a "c:" directory.
(magit-convert-git-filename directory))
;; Don't refresh the buffer we're calling from.
(process-put magit-this-process 'inhibit-refresh t)
(lambda (process event)
(when (memq (process-status process) '(exit signal))
(let ((magit-process-raise-error t))
(magit-process-sentinel process event)))
(when (and (eq (process-status process) 'exit)
(= (process-exit-status process) 0))
(with-current-buffer (process-get process 'command-buf)
(magit-status-internal directory))))))
;;; Setup
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