changeset 93123:38f18130d057

(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.
author Dan Nicolaescu <dann@ics.uci.edu>
date Fri, 21 Mar 2008 06:29:04 +0000
parents ab6a0ec29e00
children 97c5b398eee4
files lisp/ChangeLog lisp/vc-git.el
diffstat 2 files changed, 42 insertions(+), 22 deletions(-) [+]
line wrap: on
line diff
--- a/lisp/ChangeLog	Fri Mar 21 06:24:15 2008 +0000
+++ b/lisp/ChangeLog	Fri Mar 21 06:29:04 2008 +0000
@@ -1,3 +1,10 @@
+2008-03-21  Dan Nicolaescu  <dann@ics.uci.edu>
+
+	* vc-git.el (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.
+
 2008-03-21  Alexandre Julliard  <julliard@winehq.org>
 
 	* vc-git.el (vc-git-after-dir-status): Remove.
--- a/lisp/vc-git.el	Fri Mar 21 06:24:15 2008 +0000
+++ b/lisp/vc-git.el	Fri Mar 21 06:29:04 2008 +0000
@@ -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