Mercurial > emacs
comparison lisp/vc-git.el @ 93122:ab6a0ec29e00
(vc-git-after-dir-status): Remove.
(vc-git-dired-state-info): Reimplement.
author | Dan Nicolaescu <dann@ics.uci.edu> |
---|---|
date | Fri, 21 Mar 2008 06:24:15 +0000 |
parents | 01d3fd1a2cfe |
children | 38f18130d057 |
comparison
equal
deleted
inserted
replaced
93121:9e1bcf73b012 | 93122:ab6a0ec29e00 |
---|---|
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 ;;; vc-dir-status support (EXPERIMENTAL) | |
211 ;;; If vc-directory (which is not half bad under Git, w/ some tweaking) | |
212 ;;; is to go away, vc-dir-status must at least support the same operations. | |
213 ;;; At the moment, vc-dir-status design is still fluid (a kind way to say | |
214 ;;; half-baked, undocumented, and spottily-supported), so the following | |
215 ;;; should be considered likewise ripe for sudden unannounced change. | |
216 ;;; YHBW, HAND. --ttn | |
217 | |
218 (defun vc-git-after-dir-status (callback buffer) | |
219 (sort-regexp-fields t "^. \\(.+\\)$" "\\1" (point-min) (point-max)) | |
220 (let ((map '((?H . cached) | |
221 (?M . unmerged) | |
222 (?R . removed) | |
223 (?C . edited) | |
224 (?K . removed) ; ??? "to be killed" | |
225 (?? . unregistered))) | |
226 status filename result) | |
227 (goto-char (point-min)) | |
228 (while (> (point-max) (point)) | |
229 (setq status (string-to-char (buffer-substring (point) (1+ (point)))) | |
230 status (cdr (assq status map)) | |
231 filename (buffer-substring (+ 2 (point)) (line-end-position))) | |
232 ;; TODO: Add dynamic selection of which status(es) to display, and | |
233 ;; bubble that up to vc-dir-status. For now, we consider `cached' | |
234 ;; to be uninteresting, to mimic vc-directory (somewhat). | |
235 (unless (eq 'cached status) | |
236 (push (cons filename status) result)) | |
237 (forward-line 1)) | |
238 (funcall callback result buffer))) | |
239 | |
240 (defun vc-git-dir-status (dir update-function status-buffer) | 210 (defun vc-git-dir-status (dir update-function status-buffer) |
241 "Return a list of conses (file . state) for DIR." | 211 "Return a list of conses (file . state) for DIR." |
212 ;; Further things that would have to be fixed later: | |
213 ;; - support for an empty repository (with no initial commit) | |
214 ;; - how to handle unregistered directories | |
215 ;; - how to support vc-status on a subdir of the project tree | |
242 (with-current-buffer | 216 (with-current-buffer |
243 (get-buffer-create | 217 (get-buffer-create |
244 (expand-file-name " *VC-Git* tmp status" dir)) | 218 (expand-file-name " *VC-Git* tmp status" dir)) |
245 (erase-buffer) | 219 (cd dir) |
246 (vc-git-command (current-buffer) 'async dir "ls-files" "-t" | 220 (let (result) |
247 "-c" ; cached | 221 (erase-buffer) |
248 "-d" ; deleted | 222 (vc-git-command (current-buffer) 0 nil "diff-index" "-z" "HEAD") |
249 "-k" ; killed | 223 (goto-char (point-min)) |
250 "-m" ; modified | 224 (while (re-search-forward |
251 "-o" ; others | 225 ":[0-7]\\{6\\} [0-7]\\{6\\} [0-9a-f]\\{40\\} [0-9a-f]\\{40\\} \\([ADMUT]\\)\0\\([^\0]+\\)\0" |
252 "--directory" | 226 nil t 1) |
253 "--exclude-per-directory=.gitignore") | 227 (let ((filename (match-string 2)) |
254 (vc-exec-after | 228 (status (case (string-to-char( match-string 1)) |
255 `(vc-git-after-dir-status (quote ,update-function) ,status-buffer)) | 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)) | |
256 (current-buffer))) | 242 (current-buffer))) |
257 | 243 |
258 ;;; STATE-CHANGING FUNCTIONS | 244 ;;; STATE-CHANGING FUNCTIONS |
259 | 245 |
260 (defun vc-git-create-repo () | 246 (defun vc-git-create-repo () |