summaryrefslogtreecommitdiff
path: root/lisp/vc-git.el
diff options
context:
space:
mode:
authorDan Nicolaescu <dann@ics.uci.edu>2008-03-21 06:29:04 +0000
committerDan Nicolaescu <dann@ics.uci.edu>2008-03-21 06:29:04 +0000
commite345c46e5613f29d17a1c9e6c663c80925e33129 (patch)
tree0e7d9d45f516014012509aefb5fe75f5aec6b4ed /lisp/vc-git.el
parent12cb746e0a408c66ccb12c89be0fd9505d73d2b1 (diff)
downloademacs-e345c46e5613f29d17a1c9e6c663c80925e33129.tar.gz
(vc-git-status-result): New variable.
(vc-git-dir-status): Split out ... (vc-git-after-dir-status-stage1, vc-git-after-dir-status-stage2): ... these new functions and work asynchronously.
Diffstat (limited to 'lisp/vc-git.el')
-rw-r--r--lisp/vc-git.el57
1 files changed, 35 insertions, 22 deletions
diff --git a/lisp/vc-git.el b/lisp/vc-git.el
index 79a20cb62d2..888d2aaddf2 100644
--- a/lisp/vc-git.el
+++ b/lisp/vc-git.el
@@ -207,6 +207,36 @@
;; fall back to the default VC representation
(vc-default-dired-state-info 'Git file))))
+;; Variable used to keep the intermediate results for vc-git-status.
+(defvar vc-git-status-result nil)
+
+(defun vc-git-after-dir-status-stage2 (update-function status-buffer)
+ (goto-char (point-min))
+ (while (re-search-forward "\\([^\0]*?\\)\0" nil t 1)
+ (push (cons (match-string 1) 'unregistered) vc-git-status-result))
+ (funcall update-function (nreverse vc-git-status-result) status-buffer)
+ ;; Remove the temporary buffer.
+ (kill-buffer (current-buffer)))
+
+(defun vc-git-after-dir-status-stage1 (update-function status-buffer)
+ (goto-char (point-min))
+ (while (re-search-forward
+ ":[0-7]\\{6\\} [0-7]\\{6\\} [0-9a-f]\\{40\\} [0-9a-f]\\{40\\} \\([ADMUT]\\)\0\\([^\0]+\\)\0"
+ nil t 1)
+ (let ((filename (match-string 2))
+ (status (case (string-to-char( match-string 1))
+ (?M 'edited)
+ (?A 'added)
+ (?D 'removed)
+ (?U 'edited) ;; FIXME
+ (?T 'edited)))) ;; FIXME
+ (push (cons filename status) vc-git-status-result)))
+ (erase-buffer)
+ (vc-git-command (current-buffer) 'async nil "ls-files" "-z" "-o"
+ "--directory" "--no-empty-directory" "--exclude-standard")
+ (vc-exec-after
+ `(vc-git-after-dir-status-stage2 (quote ,update-function) ,status-buffer)))
+
(defun vc-git-dir-status (dir update-function status-buffer)
"Return a list of conses (file . state) for DIR."
;; Further things that would have to be fixed later:
@@ -216,29 +246,12 @@
(with-current-buffer
(get-buffer-create
(expand-file-name " *VC-Git* tmp status" dir))
+ (set (make-local-variable 'vc-git-status-result) nil)
(cd dir)
- (let (result)
- (erase-buffer)
- (vc-git-command (current-buffer) 0 nil "diff-index" "-z" "HEAD")
- (goto-char (point-min))
- (while (re-search-forward
- ":[0-7]\\{6\\} [0-7]\\{6\\} [0-9a-f]\\{40\\} [0-9a-f]\\{40\\} \\([ADMUT]\\)\0\\([^\0]+\\)\0"
- nil t 1)
- (let ((filename (match-string 2))
- (status (case (string-to-char( match-string 1))
- (?M 'edited)
- (?A 'added)
- (?D 'removed)
- (?U 'edited) ;; FIXME
- (?T 'edited)))) ;; FIXME
- (push (cons filename status) result)))
- (erase-buffer)
- (vc-git-command (current-buffer) 0 nil "ls-files" "-z" "-o"
- "--directory" "--no-empty-directory" "--exclude-standard")
- (goto-char (point-min))
- (while (re-search-forward "\\([^\0]*?\\)\0" nil t 1)
- (push (cons (match-string 1) 'unregistered) result))
- (funcall update-function (nreverse result) status-buffer))
+ (erase-buffer)
+ (vc-git-command (current-buffer) 'async nil "diff-index" "-z" "HEAD")
+ (vc-exec-after
+ `(vc-git-after-dir-status-stage1 (quote ,update-function) ,status-buffer))
(current-buffer)))
;;; STATE-CHANGING FUNCTIONS