comparison lisp/vc-git.el @ 93173:019e6794fecf

(vc-git-after-dir-status-stage1): Move state matching code ... (vc-git--state-code): ... to this new function. (vc-git-state): Use it.
author Dan Nicolaescu <dann@ics.uci.edu>
date Mon, 24 Mar 2008 08:21:43 +0000
parents c73e70274c0c
children 231f72336aed
comparison
equal deleted inserted replaced
93172:4154c9e624be 93173:019e6794fecf
139 (let ((str (buffer-string))) 139 (let ((str (buffer-string)))
140 (and (> (length str) (length name)) 140 (and (> (length str) (length name))
141 (string= (substring str 0 (1+ (length name))) 141 (string= (substring str 0 (1+ (length name)))
142 (concat name "\0"))))))))) 142 (concat name "\0")))))))))
143 143
144 (defun vc-git--state-code (code)
145 "Convert from a string to a added/deleted/modified state."
146 (case (string-to-char code)
147 (?M 'edited)
148 (?A 'added)
149 (?D 'removed)
150 (?U 'edited) ;; FIXME
151 (?T 'edited))) ;; FIXME
152
144 (defun vc-git-state (file) 153 (defun vc-git-state (file)
145 "Git-specific version of `vc-state'." 154 "Git-specific version of `vc-state'."
146 ;; FIXME: This can't set 'ignored yet 155 ;; FIXME: This can't set 'ignored yet
147 (vc-git--call nil "add" "--refresh" "--" (file-relative-name file)) 156 (vc-git--call nil "add" "--refresh" "--" (file-relative-name file))
148 (let ((diff (vc-git--run-command-string file "diff-index" "-z" "HEAD" "--"))) 157 (let ((diff (vc-git--run-command-string file "diff-index" "-z" "HEAD" "--")))
149 (if (and diff (string-match ":[0-7]\\{6\\} [0-7]\\{6\\} [0-9a-f]\\{40\\} [0-9a-f]\\{40\\} \\([ADMU]\\)\0[^\0]+\0" 158 (if (and diff (string-match ":[0-7]\\{6\\} [0-7]\\{6\\} [0-9a-f]\\{40\\} [0-9a-f]\\{40\\} \\([ADMUT]\\)\0[^\0]+\0"
150 diff)) 159 diff))
151 (if (string= (match-string 1 diff) "A") 'added 'edited) 160 (vc-git--state-code (match-string 1 diff))
152 (if (vc-git--empty-db-p) 'added 'up-to-date)))) 161 (if (vc-git--empty-db-p) 'added 'up-to-date))))
153 162
154 (defun vc-git--ls-files-state (state &rest args) 163 (defun vc-git--ls-files-state (state &rest args)
155 "Set state to STATE on all files found with git-ls-files ARGS." 164 "Set state to STATE on all files found with git-ls-files ARGS."
156 (with-temp-buffer 165 (with-temp-buffer
214 (goto-char (point-min)) 223 (goto-char (point-min))
215 (while (re-search-forward 224 (while (re-search-forward
216 ":[0-7]\\{6\\} [0-7]\\{6\\} [0-9a-f]\\{40\\} [0-9a-f]\\{40\\} \\([ADMUT]\\)\0\\([^\0]+\\)\0" 225 ":[0-7]\\{6\\} [0-7]\\{6\\} [0-9a-f]\\{40\\} [0-9a-f]\\{40\\} \\([ADMUT]\\)\0\\([^\0]+\\)\0"
217 nil t 1) 226 nil t 1)
218 (let ((filename (match-string 2)) 227 (let ((filename (match-string 2))
219 (status (case (string-to-char( match-string 1)) 228 (status (vc-git--state-code (match-string 1))))
220 (?M 'edited)
221 (?A 'added)
222 (?D 'removed)
223 (?U 'edited) ;; FIXME
224 (?T 'edited)))) ;; FIXME
225 (push (cons filename status) vc-git-status-result))) 229 (push (cons filename status) vc-git-status-result)))
226 (erase-buffer) 230 (erase-buffer)
227 (vc-git-command (current-buffer) 'async nil "ls-files" "-z" "-o" 231 (vc-git-command (current-buffer) 'async nil "ls-files" "-z" "-o"
228 "--directory" "--no-empty-directory" "--exclude-standard") 232 "--directory" "--no-empty-directory" "--exclude-standard")
229 (vc-exec-after 233 (vc-exec-after