aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDan Nicolaescu2007-08-27 18:59:41 +0000
committerDan Nicolaescu2007-08-27 18:59:41 +0000
commit00d670807ec2370ad89b816d05d8a7c40f23d28b (patch)
tree4ec0df3e2b2a052421c8e345823e0f0f21737daf
parent478adae212a3336e00622934b8c869b07001a396 (diff)
downloademacs-00d670807ec2370ad89b816d05d8a7c40f23d28b.tar.gz
emacs-00d670807ec2370ad89b816d05d8a7c40f23d28b.zip
* vc-git.el (vc-git-state): Call git-add --refresh to update the
state of the file. (vc-git-workfile-unchanged-p): Delegate implementation to vc-git-state. (vc-git-create-repo): Fixed invalid command.
-rw-r--r--lisp/ChangeLog8
-rw-r--r--lisp/vc-git.el22
2 files changed, 11 insertions, 19 deletions
diff --git a/lisp/ChangeLog b/lisp/ChangeLog
index 69fb14c19f5..fbfa25d3a5d 100644
--- a/lisp/ChangeLog
+++ b/lisp/ChangeLog
@@ -1,3 +1,11 @@
12007-08-27 Alexandre Julliard <julliard@winehq.org>
2
3 * vc-git.el (vc-git-state): Call git-add --refresh to update the
4 state of the file.
5 (vc-git-workfile-unchanged-p): Delegate implementation to
6 vc-git-state.
7 (vc-git-create-repo): Fixed invalid command.
8
12007-08-27 Richard Stallman <rms@gnu.org> 92007-08-27 Richard Stallman <rms@gnu.org>
2 10
3 * textmodes/flyspell.el (flyspell-mode): 11 * textmodes/flyspell.el (flyspell-mode):
diff --git a/lisp/vc-git.el b/lisp/vc-git.el
index 8dd6562f24b..ed4b1270972 100644
--- a/lisp/vc-git.el
+++ b/lisp/vc-git.el
@@ -143,6 +143,7 @@
143 143
144(defun vc-git-state (file) 144(defun vc-git-state (file)
145 "Git-specific version of `vc-state'." 145 "Git-specific version of `vc-state'."
146 (call-process "git" nil nil nil "add" "--refresh" "--" (file-relative-name file))
146 (let ((diff (vc-git--run-command-string file "diff-index" "-z" "HEAD" "--"))) 147 (let ((diff (vc-git--run-command-string file "diff-index" "-z" "HEAD" "--")))
147 (if (and diff (string-match ":[0-7]\\{6\\} [0-7]\\{6\\} [0-9a-f]\\{40\\} [0-9a-f]\\{40\\} [ADMU]\0[^\0]+\0" diff)) 148 (if (and diff (string-match ":[0-7]\\{6\\} [0-7]\\{6\\} [0-9a-f]\\{40\\} [0-9a-f]\\{40\\} [ADMU]\0[^\0]+\0" diff))
148 'edited 149 'edited
@@ -189,24 +190,7 @@
189 'implicit) 190 'implicit)
190 191
191(defun vc-git-workfile-unchanged-p (file) 192(defun vc-git-workfile-unchanged-p (file)
192 ;; The reason this does not use the result of vc-git-state is that 193 (eq 'up-to-date (vc-git-state file)))
193 ;; git-diff-index (used by vc-git-state) doesn't refresh the cached
194 ;; stat info, so if the file has been modified it will always show
195 ;; up as modified in vc-git-state, even if the change has been
196 ;; undone, until git-update-index --refresh is run.
197
198 ;; OTOH the vc-git-workfile-unchanged-p implementation checks the
199 ;; actual content, so it will detect the case of a file reverted
200 ;; back to its original state.
201
202 ;; The ideal implementation would be to refresh the stat cache and
203 ;; then call vc-git-state, but at the moment there's no git command
204 ;; to refresh a single file, so this will have to be added first.
205 (let ((sha1 (vc-git--run-command-string file "hash-object" "--"))
206 (head (vc-git--run-command-string file "ls-tree" "-z" "HEAD" "--")))
207 (and head
208 (string-match "[0-7]\\{6\\} blob \\([0-9a-f]\\{40\\}\\)\t[^\0]+\0" head)
209 (string= (car (split-string sha1 "\n")) (match-string 1 head)))))
210 194
211(defun vc-git-dired-state-info (file) 195(defun vc-git-dired-state-info (file)
212 "Git-specific version of `vc-dired-state-info'." 196 "Git-specific version of `vc-dired-state-info'."
@@ -220,7 +204,7 @@
220 204
221(defun vc-git-create-repo () 205(defun vc-git-create-repo ()
222 "Create a new Git repository." 206 "Create a new Git repository."
223 (vc-git-command "init" nil 0 nil)) 207 (vc-git-command nil 0 nil "init"))
224 208
225(defun vc-git-register (files &optional rev comment) 209(defun vc-git-register (files &optional rev comment)
226 "Register FILE into the git version-control system." 210 "Register FILE into the git version-control system."