Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Call git wip asynchronously #561

Merged
merged 4 commits into from
Feb 22, 2013
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 5 additions & 11 deletions magit-wip.el
Original file line number Diff line number Diff line change
Expand Up @@ -113,8 +113,8 @@ git repository then it is also committed to a special work-in-progress
ref."
:lighter magit-wip-save-mode-lighter
(if magit-wip-save-mode
(add-hook 'after-save-hook 'magit-wip-save-safe t t)
(remove-hook 'after-save-hook 'magit-wip-save-safe t)))
(add-hook 'after-save-hook 'magit-wip-save t t)
(remove-hook 'after-save-hook 'magit-wip-save t)))

;;;###autoload
(define-globalized-minor-mode global-magit-wip-save-mode
Expand All @@ -129,22 +129,16 @@ ref."
(magit-wip-save-mode 1)
(message "Git command 'git wip' cannot be found"))))

(defun magit-wip-save-safe ()
(condition-case err
(magit-wip-save)
(error
(message "Magit WIP got an error: %S" err))))

(defun magit-wip-save ()
(let* ((top-dir (magit-get-top-dir default-directory))
(name (file-truename (buffer-file-name)))
(spec `((?r . ,(file-relative-name name top-dir))
(?f . ,(buffer-file-name))
(?g . ,top-dir))))
(when (and top-dir (file-writable-p top-dir))
(magit-run-git "wip" "save"
(format-spec magit-wip-commit-message spec)
"--editor" "--" name)
(magit-run-git-async "wip" "save"
(format-spec magit-wip-commit-message spec)
"--editor" "--" name)
(when magit-wip-echo-area-message
(message (format-spec magit-wip-echo-area-message spec))))))

Expand Down
13 changes: 9 additions & 4 deletions magit.el
Original file line number Diff line number Diff line change
Expand Up @@ -2257,9 +2257,11 @@ magit-topgit and magit-svn"
(defun magit-process-sentinel (process event)
(let ((msg (format "%s %s." (process-name process) (substring event 0 -1)))
(successp (string-match "^finished" event))
(key (with-current-buffer magit-process-client-buffer
(key-description (car (where-is-internal
'magit-display-process))))))
(key (if (buffer-live-p magit-process-client-buffer)
(with-current-buffer magit-process-client-buffer
(key-description (car (where-is-internal
'magit-display-process))))
"M-x magit-display-process")))
(with-current-buffer (process-buffer process)
(let ((inhibit-read-only t))
(goto-char (point-max))
Expand All @@ -2271,7 +2273,10 @@ magit-topgit and magit-svn"
(dired-uncache default-directory)))
(setq magit-process nil)
(magit-set-mode-line-process nil)
(magit-refresh-buffer magit-process-client-buffer)))
(when (and (buffer-live-p magit-process-client-buffer)
(with-current-buffer magit-process-client-buffer
(derived-mode-p 'magit-mode)))
(magit-refresh-buffer magit-process-client-buffer))))

(defun magit-password (proc string)
"Check if git/ssh asks for a password and ask the user for it."
Expand Down