]> git.eshelyaron.com Git - emacs.git/commitdiff
(vc-git-after-dir-status-stage1): Move state matching
authorDan Nicolaescu <dann@ics.uci.edu>
Mon, 24 Mar 2008 08:21:43 +0000 (08:21 +0000)
committerDan Nicolaescu <dann@ics.uci.edu>
Mon, 24 Mar 2008 08:21:43 +0000 (08:21 +0000)
code ...
(vc-git--state-code): ... to this new function.
(vc-git-state): Use it.

lisp/ChangeLog
lisp/vc-git.el

index ccca34f2150cad4aef6b89ce1d4f19765ee541b3..91638c1dce8660d7a6562a8cc958eae5ff2166f1 100644 (file)
@@ -1,3 +1,10 @@
+2008-03-24  Alexandre Julliard  <julliard@winehq.org>
+
+       * vc-git.el (vc-git-after-dir-status-stage1): Move state matching
+       code ...
+       (vc-git--state-code): ... to this new function.
+       (vc-git-state): Use it.
+
 2008-03-24  Trent Buck  <trentbuck@gmail.com>  (tiny change)
 
        * textmodes/remember.el (remember-mail-date)
index 82c006771695bbc09b5e60f2ccdeace9c3384d36..f75c4b8b81001d70c483905d1dedfe83ddb95baa 100644 (file)
                    (string= (substring str 0 (1+ (length name)))
                              (concat name "\0")))))))))
 
+(defun vc-git--state-code (code)
+  "Convert from a string to a added/deleted/modified state."
+  (case (string-to-char code)
+    (?M 'edited)
+    (?A 'added)
+    (?D 'removed)
+    (?U 'edited)     ;; FIXME
+    (?T 'edited)))   ;; FIXME
+
 (defun vc-git-state (file)
   "Git-specific version of `vc-state'."
   ;; FIXME: This can't set 'ignored yet
   (vc-git--call nil "add" "--refresh" "--" (file-relative-name file))
   (let ((diff (vc-git--run-command-string file "diff-index" "-z" "HEAD" "--")))
-    (if (and diff (string-match ":[0-7]\\{6\\} [0-7]\\{6\\} [0-9a-f]\\{40\\} [0-9a-f]\\{40\\} \\([ADMU]\\)\0[^\0]+\0"
+    (if (and diff (string-match ":[0-7]\\{6\\} [0-7]\\{6\\} [0-9a-f]\\{40\\} [0-9a-f]\\{40\\} \\([ADMUT]\\)\0[^\0]+\0"
                                 diff))
-       (if (string= (match-string 1 diff) "A") 'added 'edited)
+        (vc-git--state-code (match-string 1 diff))
       (if (vc-git--empty-db-p) 'added 'up-to-date))))
 
 (defun vc-git--ls-files-state (state &rest args)
          ":[0-7]\\{6\\} [0-7]\\{6\\} [0-9a-f]\\{40\\} [0-9a-f]\\{40\\} \\([ADMUT]\\)\0\\([^\0]+\\)\0"
          nil t 1)
     (let ((filename (match-string 2))
-         (status (case (string-to-char( match-string 1))
-                   (?M 'edited)
-                   (?A 'added)
-                   (?D 'removed)
-                   (?U 'edited)      ;; FIXME
-                   (?T 'edited))))   ;; FIXME
+         (status (vc-git--state-code (match-string 1))))
       (push (cons filename status) vc-git-status-result)))
   (erase-buffer)
   (vc-git-command (current-buffer) 'async nil "ls-files" "-z" "-o"