diff options
| author | Dmitry Gutov | 2012-07-18 17:04:36 +0200 |
|---|---|---|
| committer | Michael Albinus | 2012-07-18 17:04:36 +0200 |
| commit | eceb6feba42bebcb15d5dd0c60c9470ad7300309 (patch) | |
| tree | f8333bd9f24d01b1426d8b4c448e38dc58c92901 | |
| parent | d7d9a499595fa8feb029988e1a6e6c5aeaf0c131 (diff) | |
| download | emacs-eceb6feba42bebcb15d5dd0c60c9470ad7300309.tar.gz emacs-eceb6feba42bebcb15d5dd0c60c9470ad7300309.zip | |
* vc/vc-git.el (vc-git-state): Don't call `vc-git-registered',
assume it's always t.
(vc-git-registered): Remove caching, the function is only called
once.
(vc-git-branches): Use `vc-git--call' instead of `call-process'.
| -rw-r--r-- | lisp/ChangeLog | 8 | ||||
| -rw-r--r-- | lisp/vc/vc-git.el | 84 |
2 files changed, 49 insertions, 43 deletions
diff --git a/lisp/ChangeLog b/lisp/ChangeLog index b0763462419..e969bd800e8 100644 --- a/lisp/ChangeLog +++ b/lisp/ChangeLog | |||
| @@ -1,3 +1,11 @@ | |||
| 1 | 2012-07-18 Dmitry Gutov <dgutov@yandex.ru> | ||
| 2 | |||
| 3 | * vc/vc-git.el (vc-git-state): Don't call `vc-git-registered', | ||
| 4 | assume it's always t. | ||
| 5 | (vc-git-registered): Remove caching, the function is only called | ||
| 6 | once. | ||
| 7 | (vc-git-branches): Use `vc-git--call' instead of `call-process'. | ||
| 8 | |||
| 1 | 2012-07-18 Chong Yidong <cyd@gnu.org> | 9 | 2012-07-18 Chong Yidong <cyd@gnu.org> |
| 2 | 10 | ||
| 3 | * subr.el (last-input-char, last-command-char): Remove (Bug#9195). | 11 | * subr.el (last-input-char, last-command-char): Remove (Bug#9195). |
diff --git a/lisp/vc/vc-git.el b/lisp/vc/vc-git.el index 4dbc9eab27f..700adf12fc2 100644 --- a/lisp/vc/vc-git.el +++ b/lisp/vc/vc-git.el | |||
| @@ -173,31 +173,28 @@ 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 | (or (vc-file-getprop file 'git-registered) | 176 | (let ((dir (vc-git-root file))) |
| 177 | (vc-file-setprop | 177 | (when dir |
| 178 | file 'git-registered | 178 | (with-temp-buffer |
| 179 | (let ((dir (vc-git-root file))) | 179 | (let* (process-file-side-effects |
| 180 | (when dir | 180 | ;; Do not use the `file-name-directory' here: git-ls-files |
| 181 | (with-temp-buffer | 181 | ;; sometimes fails to return the correct status for relative |
| 182 | (let* (process-file-side-effects | 182 | ;; path specs. |
| 183 | ;; Do not use the `file-name-directory' here: git-ls-files | 183 | ;; See also: http://marc.info/?l=git&m=125787684318129&w=2 |
| 184 | ;; sometimes fails to return the correct status for relative | 184 | (name (file-relative-name file dir)) |
| 185 | ;; path specs. | 185 | (str (ignore-errors |
| 186 | ;; See also: http://marc.info/?l=git&m=125787684318129&w=2 | 186 | (cd dir) |
| 187 | (name (file-relative-name file dir)) | 187 | (vc-git--out-ok "ls-files" "-c" "-z" "--" name) |
| 188 | (str (ignore-errors | 188 | ;; If result is empty, use ls-tree to check for deleted |
| 189 | (cd dir) | 189 | ;; file. |
| 190 | (vc-git--out-ok "ls-files" "-c" "-z" "--" name) | 190 | (when (eq (point-min) (point-max)) |
| 191 | ;; If result is empty, use ls-tree to check for deleted | 191 | (vc-git--out-ok "ls-tree" "--name-only" "-z" "HEAD" |
| 192 | ;; file. | 192 | "--" name)) |
| 193 | (when (eq (point-min) (point-max)) | 193 | (buffer-string)))) |
| 194 | (vc-git--out-ok "ls-tree" "--name-only" "-z" "HEAD" | 194 | (and str |
| 195 | "--" name)) | 195 | (> (length str) (length name)) |
| 196 | (buffer-string)))) | 196 | (string= (substring str 0 (1+ (length name))) |
| 197 | (and str | 197 | (concat name "\0")))))))) |
| 198 | (> (length str) (length name)) | ||
| 199 | (string= (substring str 0 (1+ (length name))) | ||
| 200 | (concat name "\0")))))))))) | ||
| 201 | 198 | ||
| 202 | (defun vc-git--state-code (code) | 199 | (defun vc-git--state-code (code) |
| 203 | "Convert from a string to a added/deleted/modified state." | 200 | "Convert from a string to a added/deleted/modified state." |
| @@ -218,23 +215,24 @@ matching the resulting Git log output, and KEYWORDS is a list of | |||
| 218 | ;; is direct ancestor of corresponding upstream branch, and the file | 215 | ;; is direct ancestor of corresponding upstream branch, and the file |
| 219 | ;; was modified upstream. But we can't check that without a network | 216 | ;; was modified upstream. But we can't check that without a network |
| 220 | ;; operation. | 217 | ;; operation. |
| 221 | (if (not (vc-git-registered file)) | 218 | ;; This assumes that status is known to be not `unregistered' because |
| 222 | 'unregistered | 219 | ;; we've been successfully dispatched here from `vc-state', that |
| 223 | (let ((diff (vc-git--run-command-string | 220 | ;; means `vc-git-registered' returned t earlier once. Bug#11757 |
| 224 | file "diff-index" "-p" "--raw" "-z" "HEAD" "--"))) | 221 | (let ((diff (vc-git--run-command-string |
| 225 | (if (and diff | 222 | file "diff-index" "-p" "--raw" "-z" "HEAD" "--"))) |
| 226 | (string-match ":[0-7]\\{6\\} [0-7]\\{6\\} [0-9a-f]\\{40\\} [0-9a-f]\\{40\\} \\([ADMUT]\\)\0[^\0]+\0\\(.*\n.\\)?" | 223 | (if (and diff |
| 227 | diff)) | 224 | (string-match ":[0-7]\\{6\\} [0-7]\\{6\\} [0-9a-f]\\{40\\} [0-9a-f]\\{40\\} \\([ADMUT]\\)\0[^\0]+\0\\(.*\n.\\)?" |
| 228 | (let ((diff-letter (match-string 1 diff))) | 225 | diff)) |
| 229 | (if (not (match-beginning 2)) | 226 | (let ((diff-letter (match-string 1 diff))) |
| 230 | ;; Empty diff: file contents is the same as the HEAD | 227 | (if (not (match-beginning 2)) |
| 231 | ;; revision, but timestamps are different (eg, file | 228 | ;; Empty diff: file contents is the same as the HEAD |
| 232 | ;; was "touch"ed). Update timestamp in index: | 229 | ;; revision, but timestamps are different (eg, file |
| 233 | (prog1 'up-to-date | 230 | ;; was "touch"ed). Update timestamp in index: |
| 234 | (vc-git--call nil "add" "--refresh" "--" | 231 | (prog1 'up-to-date |
| 235 | (file-relative-name file))) | 232 | (vc-git--call nil "add" "--refresh" "--" |
| 236 | (vc-git--state-code diff-letter))) | 233 | (file-relative-name file))) |
| 237 | (if (vc-git--empty-db-p) 'added 'up-to-date))))) | 234 | (vc-git--state-code diff-letter))) |
| 235 | (if (vc-git--empty-db-p) 'added 'up-to-date)))) | ||
| 238 | 236 | ||
| 239 | (defun vc-git-working-revision (_file) | 237 | (defun vc-git-working-revision (_file) |
| 240 | "Git-specific version of `vc-working-revision'." | 238 | "Git-specific version of `vc-working-revision'." |
| @@ -576,7 +574,7 @@ or an empty string if none." | |||
| 576 | "Return the existing branches, as a list of strings. | 574 | "Return the existing branches, as a list of strings. |
| 577 | The car of the list is the current branch." | 575 | The car of the list is the current branch." |
| 578 | (with-temp-buffer | 576 | (with-temp-buffer |
| 579 | (call-process vc-git-program nil t nil "branch") | 577 | (vc-git--call t "branch") |
| 580 | (goto-char (point-min)) | 578 | (goto-char (point-min)) |
| 581 | (let (current-branch branches) | 579 | (let (current-branch branches) |
| 582 | (while (not (eobp)) | 580 | (while (not (eobp)) |