comparison lisp/vc-git.el @ 91929:3299b785d830

(vc-git-after-dir-status, vc-git-dir-status): New funcs.
author Thien-Thi Nguyen <ttn@gnuvola.org>
date Mon, 18 Feb 2008 07:46:14 +0000
parents 107ccd98fa12
children a0193ceeaa83
comparison
equal deleted inserted replaced
91928:e788f311729d 91929:3299b785d830
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)
241 "Return a list of conses (file . state) for DIR."
242 (with-current-buffer
243 (get-buffer-create
244 (expand-file-name " *VC-Git* tmp status" dir))
245 (erase-buffer)
246 (vc-git-command (current-buffer) 'async dir "ls-files" "-t"
247 "-c" ; cached
248 "-d" ; deleted
249 "-k" ; killed
250 "-m" ; modified
251 "-o" ; others
252 "--directory"
253 "--exclude-per-directory=.gitignore")
254 (vc-exec-after
255 `(vc-git-after-dir-status (quote ,update-function) ,status-buffer))))
256
210 ;;; STATE-CHANGING FUNCTIONS 257 ;;; STATE-CHANGING FUNCTIONS
211 258
212 (defun vc-git-create-repo () 259 (defun vc-git-create-repo ()
213 "Create a new Git repository." 260 "Create a new Git repository."
214 (vc-git-command nil 0 nil "init")) 261 (vc-git-command nil 0 nil "init"))