diff options
| -rw-r--r-- | lisp/ChangeLog | 8 | ||||
| -rw-r--r-- | lisp/vc/vc-git.el | 52 |
2 files changed, 36 insertions, 24 deletions
diff --git a/lisp/ChangeLog b/lisp/ChangeLog index d92783e03b0..17e30de8f61 100644 --- a/lisp/ChangeLog +++ b/lisp/ChangeLog | |||
| @@ -1,3 +1,11 @@ | |||
| 1 | 2012-06-30 Michael Albinus <michael.albinus@gmx.de> | ||
| 2 | |||
| 3 | * vc/vc-git.el (vc-git-registered): Use cache property | ||
| 4 | `git-registered'. | ||
| 5 | (vc-git-mode-line-string): Call `vc-working-revision' instead of | ||
| 6 | `vc-git-working-revision' in order to benefit from the cache. | ||
| 7 | (vc-git-root): Use cache property `git-root'. | ||
| 8 | |||
| 1 | 2012-06-30 Dmitry Gutov <dgutov@yandex.ru> | 9 | 2012-06-30 Dmitry Gutov <dgutov@yandex.ru> |
| 2 | 10 | ||
| 3 | * vc/vc-hooks.el (vc-before-save): Clear cache if file has been | 11 | * vc/vc-hooks.el (vc-before-save): Clear cache if file has been |
diff --git a/lisp/vc/vc-git.el b/lisp/vc/vc-git.el index 63243cdbc20..8b48efbfd24 100644 --- a/lisp/vc/vc-git.el +++ b/lisp/vc/vc-git.el | |||
| @@ -173,28 +173,31 @@ matching the resulting Git log output, and KEYWORDS is a list of | |||
| 173 | 173 | ||
| 174 | (defun vc-git-registered (file) | 174 | (defun vc-git-registered (file) |
| 175 | "Check whether FILE is registered with git." | 175 | "Check whether FILE is registered with git." |
| 176 | (let ((dir (vc-git-root file))) | 176 | (or (vc-file-getprop file 'git-registered) |
| 177 | (when dir | 177 | (vc-file-setprop |
| 178 | (with-temp-buffer | 178 | file 'git-registered |
| 179 | (let* (process-file-side-effects | 179 | (let ((dir (vc-git-root file))) |
| 180 | ;; Do not use the `file-name-directory' here: git-ls-files | 180 | (when dir |
| 181 | ;; sometimes fails to return the correct status for relative | 181 | (with-temp-buffer |
| 182 | ;; path specs. | 182 | (let* (process-file-side-effects |
| 183 | ;; See also: http://marc.info/?l=git&m=125787684318129&w=2 | 183 | ;; Do not use the `file-name-directory' here: git-ls-files |
| 184 | (name (file-relative-name file dir)) | 184 | ;; sometimes fails to return the correct status for relative |
| 185 | (str (ignore-errors | 185 | ;; path specs. |
| 186 | (cd dir) | 186 | ;; See also: http://marc.info/?l=git&m=125787684318129&w=2 |
| 187 | (vc-git--out-ok "ls-files" "-c" "-z" "--" name) | 187 | (name (file-relative-name file dir)) |
| 188 | ;; If result is empty, use ls-tree to check for deleted | 188 | (str (ignore-errors |
| 189 | ;; file. | 189 | (cd dir) |
| 190 | (when (eq (point-min) (point-max)) | 190 | (vc-git--out-ok "ls-files" "-c" "-z" "--" name) |
| 191 | (vc-git--out-ok "ls-tree" "--name-only" "-z" "HEAD" | 191 | ;; If result is empty, use ls-tree to check for deleted |
| 192 | "--" name)) | 192 | ;; file. |
| 193 | (buffer-string)))) | 193 | (when (eq (point-min) (point-max)) |
| 194 | (and str | 194 | (vc-git--out-ok "ls-tree" "--name-only" "-z" "HEAD" |
| 195 | (> (length str) (length name)) | 195 | "--" name)) |
| 196 | (string= (substring str 0 (1+ (length name))) | 196 | (buffer-string)))) |
| 197 | (concat name "\0")))))))) | 197 | (and str |
| 198 | (> (length str) (length name)) | ||
| 199 | (string= (substring str 0 (1+ (length name))) | ||
| 200 | (concat name "\0")))))))))) | ||
| 198 | 201 | ||
| 199 | (defun vc-git--state-code (code) | 202 | (defun vc-git--state-code (code) |
| 200 | "Convert from a string to a added/deleted/modified state." | 203 | "Convert from a string to a added/deleted/modified state." |
| @@ -248,7 +251,7 @@ matching the resulting Git log output, and KEYWORDS is a list of | |||
| 248 | 251 | ||
| 249 | (defun vc-git-mode-line-string (file) | 252 | (defun vc-git-mode-line-string (file) |
| 250 | "Return a string for `vc-mode-line' to put in the mode line for FILE." | 253 | "Return a string for `vc-mode-line' to put in the mode line for FILE." |
| 251 | (let* ((branch (vc-git-working-revision file)) | 254 | (let* ((branch (vc-working-revision file)) |
| 252 | (def-ml (vc-default-mode-line-string 'Git file)) | 255 | (def-ml (vc-default-mode-line-string 'Git file)) |
| 253 | (help-echo (get-text-property 0 'help-echo def-ml))) | 256 | (help-echo (get-text-property 0 'help-echo def-ml))) |
| 254 | (if (zerop (length branch)) | 257 | (if (zerop (length branch)) |
| @@ -959,7 +962,8 @@ or BRANCH^ (where \"^\" can be repeated)." | |||
| 959 | (defun vc-git-extra-status-menu () vc-git-extra-menu-map) | 962 | (defun vc-git-extra-status-menu () vc-git-extra-menu-map) |
| 960 | 963 | ||
| 961 | (defun vc-git-root (file) | 964 | (defun vc-git-root (file) |
| 962 | (vc-find-root file ".git")) | 965 | (or (vc-file-getprop file 'git-root) |
| 966 | (vc-file-setprop file 'git-root (vc-find-root file ".git")))) | ||
| 963 | 967 | ||
| 964 | ;; Derived from `lgrep'. | 968 | ;; Derived from `lgrep'. |
| 965 | (defun vc-git-grep (regexp &optional files dir) | 969 | (defun vc-git-grep (regexp &optional files dir) |