# HG changeset patch # User Dan Nicolaescu # Date 1206080944 0 # Node ID 38f18130d05759a09aa1530e04c98c1cb62859ba # Parent ab6a0ec29e00846fd4b09a0a7664cfec214839d6 (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. diff -r ab6a0ec29e00 -r 38f18130d057 lisp/ChangeLog --- 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 + + * 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 * vc-git.el (vc-git-after-dir-status): Remove. diff -r ab6a0ec29e00 -r 38f18130d057 lisp/vc-git.el --- 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