diff options
| -rw-r--r-- | lisp/ChangeLog | 4 | ||||
| -rw-r--r-- | lisp/vc-git.el | 40 |
2 files changed, 24 insertions, 20 deletions
diff --git a/lisp/ChangeLog b/lisp/ChangeLog index 4a1e8099439..aa6ee15c00f 100644 --- a/lisp/ChangeLog +++ b/lisp/ChangeLog | |||
| @@ -1,3 +1,7 @@ | |||
| 1 | 2009-11-30 Dan Nicolaescu <dann@ics.uci.edu> | ||
| 2 | |||
| 3 | * vc-git.el (vc-git-registered): Call vc-git-root only once. | ||
| 4 | |||
| 1 | 2009-11-30 Juri Linkov <juri@jurta.org> | 5 | 2009-11-30 Juri Linkov <juri@jurta.org> |
| 2 | 6 | ||
| 3 | * misearch.el (multi-isearch-read-buffers): Move canonicalization | 7 | * misearch.el (multi-isearch-read-buffers): Move canonicalization |
diff --git a/lisp/vc-git.el b/lisp/vc-git.el index 4c577953262..a4e01e8d8c5 100644 --- a/lisp/vc-git.el +++ b/lisp/vc-git.el | |||
| @@ -144,26 +144,26 @@ If nil, use the value of `vc-diff-switches'. If t, use no switches." | |||
| 144 | 144 | ||
| 145 | (defun vc-git-registered (file) | 145 | (defun vc-git-registered (file) |
| 146 | "Check whether FILE is registered with git." | 146 | "Check whether FILE is registered with git." |
| 147 | (when (vc-git-root file) | 147 | (let ((dir (vc-git-root file))) |
| 148 | (with-temp-buffer | 148 | (when dir |
| 149 | (let* (process-file-side-effects | 149 | (with-temp-buffer |
| 150 | ;; do not use the `file-name-directory' here: git-ls-files | 150 | (let* (process-file-side-effects |
| 151 | ;; sometimes fails to return the correct status for relative | 151 | ;; Do not use the `file-name-directory' here: git-ls-files |
| 152 | ;; path specs. | 152 | ;; sometimes fails to return the correct status for relative |
| 153 | ;; see also: http://marc.info/?l=git&m=125787684318129&w=2 | 153 | ;; path specs. |
| 154 | (dir (vc-git-root file)) | 154 | ;; See also: http://marc.info/?l=git&m=125787684318129&w=2 |
| 155 | (name (file-relative-name file dir)) | 155 | (name (file-relative-name file dir)) |
| 156 | (str (ignore-errors | 156 | (str (ignore-errors |
| 157 | (when dir (cd dir)) | 157 | (cd dir) |
| 158 | (vc-git--out-ok "ls-files" "-c" "-z" "--" name) | 158 | (vc-git--out-ok "ls-files" "-c" "-z" "--" name) |
| 159 | ;; if result is empty, use ls-tree to check for deleted file | 159 | ;; if result is empty, use ls-tree to check for deleted file |
| 160 | (when (eq (point-min) (point-max)) | 160 | (when (eq (point-min) (point-max)) |
| 161 | (vc-git--out-ok "ls-tree" "--name-only" "-z" "HEAD" "--" name)) | 161 | (vc-git--out-ok "ls-tree" "--name-only" "-z" "HEAD" "--" name)) |
| 162 | (buffer-string)))) | 162 | (buffer-string)))) |
| 163 | (and str | 163 | (and str |
| 164 | (> (length str) (length name)) | 164 | (> (length str) (length name)) |
| 165 | (string= (substring str 0 (1+ (length name))) | 165 | (string= (substring str 0 (1+ (length name))) |
| 166 | (concat name "\0"))))))) | 166 | (concat name "\0")))))))) |
| 167 | 167 | ||
| 168 | (defun vc-git--state-code (code) | 168 | (defun vc-git--state-code (code) |
| 169 | "Convert from a string to a added/deleted/modified state." | 169 | "Convert from a string to a added/deleted/modified state." |