diff options
| author | Michael Albinus | 2009-08-25 09:01:38 +0000 |
|---|---|---|
| committer | Michael Albinus | 2009-08-25 09:01:38 +0000 |
| commit | 20c76c553cafa2ea32d456acc034021c00ff285d (patch) | |
| tree | fce9881de6bb123b6f87c52456f9d7dc078d4c89 | |
| parent | 4968879cda343b714a85eb606b3e67264203e933 (diff) | |
| download | emacs-20c76c553cafa2ea32d456acc034021c00ff285d.tar.gz emacs-20c76c553cafa2ea32d456acc034021c00ff285d.zip | |
* vc-git.el (vc-git-registered, vc-git-working-revision)
(vc-git-find-revision, vc-git-diff, vc-git-revision-table)
(vc-git--empty-db-p): Let-bind `process-file-side-effects' with nil.
| -rw-r--r-- | lisp/vc-git.el | 44 |
1 files changed, 25 insertions, 19 deletions
diff --git a/lisp/vc-git.el b/lisp/vc-git.el index 0d35afa739e..923ea63acf8 100644 --- a/lisp/vc-git.el +++ b/lisp/vc-git.el | |||
| @@ -146,7 +146,8 @@ If nil, use the value of `vc-diff-switches'. If t, use no switches." | |||
| 146 | "Check whether FILE is registered with git." | 146 | "Check whether FILE is registered with git." |
| 147 | (when (vc-git-root file) | 147 | (when (vc-git-root file) |
| 148 | (with-temp-buffer | 148 | (with-temp-buffer |
| 149 | (let* ((dir (file-name-directory file)) | 149 | (let* (process-file-side-effects |
| 150 | (dir (file-name-directory file)) | ||
| 150 | (name (file-relative-name file dir)) | 151 | (name (file-relative-name file dir)) |
| 151 | (str (ignore-errors | 152 | (str (ignore-errors |
| 152 | (when dir (cd dir)) | 153 | (when dir (cd dir)) |
| @@ -183,9 +184,10 @@ If nil, use the value of `vc-diff-switches'. If t, use no switches." | |||
| 183 | 184 | ||
| 184 | (defun vc-git-working-revision (file) | 185 | (defun vc-git-working-revision (file) |
| 185 | "Git-specific version of `vc-working-revision'." | 186 | "Git-specific version of `vc-working-revision'." |
| 186 | (let ((str (with-output-to-string | 187 | (let* (process-file-side-effects |
| 187 | (with-current-buffer standard-output | 188 | (str (with-output-to-string |
| 188 | (vc-git--out-ok "symbolic-ref" "HEAD"))))) | 189 | (with-current-buffer standard-output |
| 190 | (vc-git--out-ok "symbolic-ref" "HEAD"))))) | ||
| 189 | (if (string-match "^\\(refs/heads/\\)?\\(.+\\)$" str) | 191 | (if (string-match "^\\(refs/heads/\\)?\\(.+\\)$" str) |
| 190 | (match-string 2 str) | 192 | (match-string 2 str) |
| 191 | str))) | 193 | str))) |
| @@ -260,7 +262,7 @@ If nil, use the value of `vc-diff-switches'. If t, use no switches." | |||
| 260 | 262 | ||
| 261 | (defun vc-git-rename-as-string (state extra) | 263 | (defun vc-git-rename-as-string (state extra) |
| 262 | "Return a string describing the copy or rename associated with INFO, or an empty string if none." | 264 | "Return a string describing the copy or rename associated with INFO, or an empty string if none." |
| 263 | (let ((rename-state (when extra | 265 | (let ((rename-state (when extra |
| 264 | (vc-git-extra-fileinfo->rename-state extra)))) | 266 | (vc-git-extra-fileinfo->rename-state extra)))) |
| 265 | (if rename-state | 267 | (if rename-state |
| 266 | (propertize | 268 | (propertize |
| @@ -406,7 +408,7 @@ If nil, use the value of `vc-diff-switches'. If t, use no switches." | |||
| 406 | (when (string= stash "") (setq stash "Nothing stashed")) | 408 | (when (string= stash "") (setq stash "Nothing stashed")) |
| 407 | (concat | 409 | (concat |
| 408 | (propertize "Branch : " 'face 'font-lock-type-face) | 410 | (propertize "Branch : " 'face 'font-lock-type-face) |
| 409 | (propertize | 411 | (propertize |
| 410 | (if (string-match "^\\(refs/heads/\\)?\\(.+\\)$" str) | 412 | (if (string-match "^\\(refs/heads/\\)?\\(.+\\)$" str) |
| 411 | (match-string 2 str) | 413 | (match-string 2 str) |
| 412 | "not (detached HEAD)") | 414 | "not (detached HEAD)") |
| @@ -439,12 +441,13 @@ If nil, use the value of `vc-diff-switches'. If t, use no switches." | |||
| 439 | (if vc-git-add-signoff "-s") "-m" comment "--only" "--"))) | 441 | (if vc-git-add-signoff "-s") "-m" comment "--only" "--"))) |
| 440 | 442 | ||
| 441 | (defun vc-git-find-revision (file rev buffer) | 443 | (defun vc-git-find-revision (file rev buffer) |
| 442 | (let ((coding-system-for-read 'binary) | 444 | (let* (process-file-side-effects |
| 443 | (coding-system-for-write 'binary) | 445 | (coding-system-for-read 'binary) |
| 444 | (fullname (substring | 446 | (coding-system-for-write 'binary) |
| 445 | (vc-git--run-command-string | 447 | (fullname (substring |
| 446 | file "ls-files" "-z" "--full-name" "--") | 448 | (vc-git--run-command-string |
| 447 | 0 -1))) | 449 | file "ls-files" "-z" "--full-name" "--") |
| 450 | 0 -1))) | ||
| 448 | (vc-git-command | 451 | (vc-git-command |
| 449 | buffer 0 | 452 | buffer 0 |
| 450 | (concat (if rev rev "HEAD") ":" fullname) "cat-file" "blob"))) | 453 | (concat (if rev rev "HEAD") ":" fullname) "cat-file" "blob"))) |
| @@ -528,15 +531,17 @@ or BRANCH^ (where \"^\" can be repeated)." | |||
| 528 | 531 | ||
| 529 | (defun vc-git-diff (files &optional rev1 rev2 buffer) | 532 | (defun vc-git-diff (files &optional rev1 rev2 buffer) |
| 530 | "Get a difference report using Git between two revisions of FILES." | 533 | "Get a difference report using Git between two revisions of FILES." |
| 531 | (apply #'vc-git-command (or buffer "*vc-diff*") 1 files | 534 | (let (process-file-side-effects) |
| 532 | (if (and rev1 rev2) "diff-tree" "diff-index") | 535 | (apply #'vc-git-command (or buffer "*vc-diff*") 1 files |
| 533 | "--exit-code" | 536 | (if (and rev1 rev2) "diff-tree" "diff-index") |
| 534 | (append (vc-switches 'git 'diff) | 537 | "--exit-code" |
| 535 | (list "-p" (or rev1 "HEAD") rev2 "--")))) | 538 | (append (vc-switches 'git 'diff) |
| 539 | (list "-p" (or rev1 "HEAD") rev2 "--"))))) | ||
| 536 | 540 | ||
| 537 | (defun vc-git-revision-table (files) | 541 | (defun vc-git-revision-table (files) |
| 538 | ;; What about `files'?!? --Stef | 542 | ;; What about `files'?!? --Stef |
| 539 | (let ((table (list "HEAD"))) | 543 | (let (process-file-side-effects |
| 544 | (table (list "HEAD"))) | ||
| 540 | (with-temp-buffer | 545 | (with-temp-buffer |
| 541 | (vc-git-command t nil nil "for-each-ref" "--format=%(refname)") | 546 | (vc-git-command t nil nil "for-each-ref" "--format=%(refname)") |
| 542 | (goto-char (point-min)) | 547 | (goto-char (point-min)) |
| @@ -736,7 +741,8 @@ The difference to vc-do-command is that this function always invokes `git'." | |||
| 736 | 741 | ||
| 737 | (defun vc-git--empty-db-p () | 742 | (defun vc-git--empty-db-p () |
| 738 | "Check if the git db is empty (no commit done yet)." | 743 | "Check if the git db is empty (no commit done yet)." |
| 739 | (not (eq 0 (vc-git--call nil "rev-parse" "--verify" "HEAD")))) | 744 | (let (process-file-side-effects) |
| 745 | (not (eq 0 (vc-git--call nil "rev-parse" "--verify" "HEAD"))))) | ||
| 740 | 746 | ||
| 741 | (defun vc-git--call (buffer command &rest args) | 747 | (defun vc-git--call (buffer command &rest args) |
| 742 | ;; We don't need to care the arguments. If there is a file name, it | 748 | ;; We don't need to care the arguments. If there is a file name, it |