Mercurial > emacs
comparison lisp/vc-git.el @ 87525:77d4b0e5e5d2
* vc-git.el (vc-git--ls-files-state): New function.
(vc-git-dir-state): Use it instead of processing the status
results here.
author | Dan Nicolaescu <dann@ics.uci.edu> |
---|---|
date | Thu, 03 Jan 2008 06:29:38 +0000 |
parents | de0bd1c6cbfd |
children | 7ae99e295dfd |
comparison
equal
deleted
inserted
replaced
87524:7a64dd146336 | 87525:77d4b0e5e5d2 |
---|---|
149 (if (and diff (string-match ":[0-7]\\{6\\} [0-7]\\{6\\} [0-9a-f]\\{40\\} [0-9a-f]\\{40\\} [ADMU]\0[^\0]+\0" | 149 (if (and diff (string-match ":[0-7]\\{6\\} [0-7]\\{6\\} [0-9a-f]\\{40\\} [0-9a-f]\\{40\\} [ADMU]\0[^\0]+\0" |
150 diff)) | 150 diff)) |
151 'edited | 151 'edited |
152 'up-to-date))) | 152 'up-to-date))) |
153 | 153 |
154 (defun vc-git--ls-files-state (state &rest args) | |
155 "Set state to STATE on all files found with git-ls-files ARGS." | |
156 (with-temp-buffer | |
157 (apply 'vc-git-command (current-buffer) nil nil "ls-files" "-z" args) | |
158 (goto-char (point-min)) | |
159 (let ((start (point))) | |
160 (while (search-forward "\0" nil t) | |
161 (let ((file (expand-file-name | |
162 (buffer-substring-no-properties start (1- (point)))))) | |
163 (vc-file-setprop file 'vc-backend (if state 'Git 'none)) | |
164 (vc-file-setprop file 'vc-state state)) | |
165 (setq start (point)))))) | |
166 | |
154 (defun vc-git-dir-state (dir) | 167 (defun vc-git-dir-state (dir) |
155 "Git-specific version of `dir-state'." | 168 "Git-specific version of `dir-state'." |
156 ;; FIXME: This can't set 'ignored yet | 169 (vc-git--ls-files-state 'up-to-date "-c") |
157 (with-temp-buffer | 170 (vc-git--ls-files-state 'edited "-m") |
158 (vc-git-command (current-buffer) nil nil "ls-files" "-t" "-c" "-m" "-o") | 171 (vc-git--ls-files-state 'removed "-d") |
159 (goto-char (point-min)) | 172 (vc-git--ls-files-state 'ignored "-o" "-i" "--exclude-standard") |
160 (let ((status-char nil) | 173 (vc-git--ls-files-state nil "-o" "--exclude-standard")) |
161 (file nil)) | |
162 (while (not (eobp)) | |
163 (setq status-char (char-after)) | |
164 (setq file | |
165 (expand-file-name | |
166 (buffer-substring-no-properties (+ (point) 2) | |
167 (line-end-position)))) | |
168 (cond | |
169 ;; The rest of the possible states in "git ls-files -t" output: | |
170 ;; K to be killed | |
171 ;; should not show up in vc-dired, so don't deal with them | |
172 ;; here. | |
173 ((eq status-char ?H) | |
174 (vc-file-setprop file 'vc-backend 'Git) | |
175 (vc-file-setprop file 'vc-state 'up-to-date)) | |
176 ((eq status-char ?R) | |
177 (vc-file-setprop file 'vc-backend 'Git) | |
178 (vc-file-setprop file 'vc-state 'removed)) | |
179 ((eq status-char ?M) | |
180 (vc-file-setprop file 'vc-backend 'Git) | |
181 (vc-file-setprop file 'vc-state 'edited)) | |
182 ((eq status-char ?C) | |
183 (vc-file-setprop file 'vc-backend 'Git) | |
184 (vc-file-setprop file 'vc-state 'edited)) | |
185 ((eq status-char ??) | |
186 (vc-file-setprop file 'vc-backend 'none) | |
187 (vc-file-setprop file 'vc-state nil))) | |
188 (forward-line))))) | |
189 | 174 |
190 (defun vc-git-working-revision (file) | 175 (defun vc-git-working-revision (file) |
191 "Git-specific version of `vc-working-revision'." | 176 "Git-specific version of `vc-working-revision'." |
192 (let ((str (with-output-to-string | 177 (let ((str (with-output-to-string |
193 (with-current-buffer standard-output | 178 (with-current-buffer standard-output |