Mercurial > emacs
comparison lisp/vc-git.el @ 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 |
comparison
equal
deleted
inserted
replaced
93122:ab6a0ec29e00 | 93123:38f18130d057 |
---|---|
205 (if (eq git-state 'edited) | 205 (if (eq git-state 'edited) |
206 "(modified)" | 206 "(modified)" |
207 ;; fall back to the default VC representation | 207 ;; fall back to the default VC representation |
208 (vc-default-dired-state-info 'Git file)))) | 208 (vc-default-dired-state-info 'Git file)))) |
209 | 209 |
210 ;; Variable used to keep the intermediate results for vc-git-status. | |
211 (defvar vc-git-status-result nil) | |
212 | |
213 (defun vc-git-after-dir-status-stage2 (update-function status-buffer) | |
214 (goto-char (point-min)) | |
215 (while (re-search-forward "\\([^\0]*?\\)\0" nil t 1) | |
216 (push (cons (match-string 1) 'unregistered) vc-git-status-result)) | |
217 (funcall update-function (nreverse vc-git-status-result) status-buffer) | |
218 ;; Remove the temporary buffer. | |
219 (kill-buffer (current-buffer))) | |
220 | |
221 (defun vc-git-after-dir-status-stage1 (update-function status-buffer) | |
222 (goto-char (point-min)) | |
223 (while (re-search-forward | |
224 ":[0-7]\\{6\\} [0-7]\\{6\\} [0-9a-f]\\{40\\} [0-9a-f]\\{40\\} \\([ADMUT]\\)\0\\([^\0]+\\)\0" | |
225 nil t 1) | |
226 (let ((filename (match-string 2)) | |
227 (status (case (string-to-char( match-string 1)) | |
228 (?M 'edited) | |
229 (?A 'added) | |
230 (?D 'removed) | |
231 (?U 'edited) ;; FIXME | |
232 (?T 'edited)))) ;; FIXME | |
233 (push (cons filename status) vc-git-status-result))) | |
234 (erase-buffer) | |
235 (vc-git-command (current-buffer) 'async nil "ls-files" "-z" "-o" | |
236 "--directory" "--no-empty-directory" "--exclude-standard") | |
237 (vc-exec-after | |
238 `(vc-git-after-dir-status-stage2 (quote ,update-function) ,status-buffer))) | |
239 | |
210 (defun vc-git-dir-status (dir update-function status-buffer) | 240 (defun vc-git-dir-status (dir update-function status-buffer) |
211 "Return a list of conses (file . state) for DIR." | 241 "Return a list of conses (file . state) for DIR." |
212 ;; Further things that would have to be fixed later: | 242 ;; Further things that would have to be fixed later: |
213 ;; - support for an empty repository (with no initial commit) | 243 ;; - support for an empty repository (with no initial commit) |
214 ;; - how to handle unregistered directories | 244 ;; - how to handle unregistered directories |
215 ;; - how to support vc-status on a subdir of the project tree | 245 ;; - how to support vc-status on a subdir of the project tree |
216 (with-current-buffer | 246 (with-current-buffer |
217 (get-buffer-create | 247 (get-buffer-create |
218 (expand-file-name " *VC-Git* tmp status" dir)) | 248 (expand-file-name " *VC-Git* tmp status" dir)) |
249 (set (make-local-variable 'vc-git-status-result) nil) | |
219 (cd dir) | 250 (cd dir) |
220 (let (result) | 251 (erase-buffer) |
221 (erase-buffer) | 252 (vc-git-command (current-buffer) 'async nil "diff-index" "-z" "HEAD") |
222 (vc-git-command (current-buffer) 0 nil "diff-index" "-z" "HEAD") | 253 (vc-exec-after |
223 (goto-char (point-min)) | 254 `(vc-git-after-dir-status-stage1 (quote ,update-function) ,status-buffer)) |
224 (while (re-search-forward | |
225 ":[0-7]\\{6\\} [0-7]\\{6\\} [0-9a-f]\\{40\\} [0-9a-f]\\{40\\} \\([ADMUT]\\)\0\\([^\0]+\\)\0" | |
226 nil t 1) | |
227 (let ((filename (match-string 2)) | |
228 (status (case (string-to-char( match-string 1)) | |
229 (?M 'edited) | |
230 (?A 'added) | |
231 (?D 'removed) | |
232 (?U 'edited) ;; FIXME | |
233 (?T 'edited)))) ;; FIXME | |
234 (push (cons filename status) result))) | |
235 (erase-buffer) | |
236 (vc-git-command (current-buffer) 0 nil "ls-files" "-z" "-o" | |
237 "--directory" "--no-empty-directory" "--exclude-standard") | |
238 (goto-char (point-min)) | |
239 (while (re-search-forward "\\([^\0]*?\\)\0" nil t 1) | |
240 (push (cons (match-string 1) 'unregistered) result)) | |
241 (funcall update-function (nreverse result) status-buffer)) | |
242 (current-buffer))) | 255 (current-buffer))) |
243 | 256 |
244 ;;; STATE-CHANGING FUNCTIONS | 257 ;;; STATE-CHANGING FUNCTIONS |
245 | 258 |
246 (defun vc-git-create-repo () | 259 (defun vc-git-create-repo () |