comparison lisp/vc-git.el @ 82843:768766d373a7

* vc-git.el (vc-git-mode-line-string): New function.
author Dan Nicolaescu <dann@ics.uci.edu>
date Sat, 25 Aug 2007 20:04:26 +0000
parents 36893fdf92ab
children 5039706521c9
comparison
equal deleted inserted replaced
82842:c71eaf555f05 82843:768766d373a7
55 ;; - dir-state (dir) OK 55 ;; - dir-state (dir) OK
56 ;; * workfile-version (file) OK 56 ;; * workfile-version (file) OK
57 ;; - latest-on-branch-p (file) NOT NEEDED 57 ;; - latest-on-branch-p (file) NOT NEEDED
58 ;; * checkout-model (file) OK 58 ;; * checkout-model (file) OK
59 ;; - workfile-unchanged-p (file) OK 59 ;; - workfile-unchanged-p (file) OK
60 ;; - mode-line-string (file) NOT NEEDED 60 ;; - mode-line-string (file) OK
61 ;; - dired-state-info (file) OK 61 ;; - dired-state-info (file) OK
62 ;; STATE-CHANGING FUNCTIONS 62 ;; STATE-CHANGING FUNCTIONS
63 ;; * create-repo () OK 63 ;; * create-repo () OK
64 ;; * register (files &optional rev comment) OK 64 ;; * register (files &optional rev comment) OK
65 ;; - init-version (file) NOT NEEDED 65 ;; - init-version (file) NOT NEEDED
206 (head (vc-git--run-command-string file "ls-tree" "-z" "HEAD" "--"))) 206 (head (vc-git--run-command-string file "ls-tree" "-z" "HEAD" "--")))
207 (and head 207 (and head
208 (string-match "[0-7]\\{6\\} blob \\([0-9a-f]\\{40\\}\\)\t[^\0]+\0" 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))))) 209 (string= (car (split-string sha1 "\n")) (match-string 1 head)))))
210 210
211 (defun vc-git-mode-line-string (file)
212 "Return string for placement into the modeline for FILE."
213 (let* ((branch (vc-git-workfile-version file))
214 (def-ml (vc-default-mode-line-string 'Git file))
215 (help-echo (get-text-property 0 'help-echo def-ml)))
216 (if (zerop (length branch))
217 (propertize
218 (concat def-ml "!")
219 'help-echo (concat help-echo "\nNo current branch (detached HEAD)"))
220 (propertize def-ml
221 'help-echo (concat help-echo "\nCurrent branch: " branch)))))
222
211 (defun vc-git-dired-state-info (file) 223 (defun vc-git-dired-state-info (file)
212 "Git-specific version of `vc-dired-state-info'." 224 "Git-specific version of `vc-dired-state-info'."
213 (let ((git-state (vc-state file))) 225 (let ((git-state (vc-state file)))
214 (if (eq git-state 'edited) 226 (if (eq git-state 'edited)
215 "(modified)" 227 "(modified)"