Mercurial > emacs
comparison lisp/vc-git.el @ 109261:5f75bdff36e4
Fix vc-annotate for renamed files when using Git.
* lisp/vc-git.el (vc-git-find-revision): Deal with empty results from
ls-files. Doe not pass the object as a file name to cat-file, it
is not a file name.
(vc-git-annotate-command): Pass the file name using -- to avoid
ambiguity with the revision.
(vc-git-previous-revision): Pass a relative file name.
author | Dan Nicolaescu <dann@ics.uci.edu> |
---|---|
date | Tue, 22 Jun 2010 12:25:17 -0700 |
parents | e60e30383efd |
children | 8027e412df98 |
comparison
equal
deleted
inserted
replaced
109260:1359517bb5ef | 109261:5f75bdff36e4 |
---|---|
549 | 549 |
550 (defun vc-git-find-revision (file rev buffer) | 550 (defun vc-git-find-revision (file rev buffer) |
551 (let* (process-file-side-effects | 551 (let* (process-file-side-effects |
552 (coding-system-for-read 'binary) | 552 (coding-system-for-read 'binary) |
553 (coding-system-for-write 'binary) | 553 (coding-system-for-write 'binary) |
554 (fullname (substring | 554 (fullname |
555 (vc-git--run-command-string | 555 (let ((fn (vc-git--run-command-string |
556 file "ls-files" "-z" "--full-name" "--") | 556 file "ls-files" "-z" "--full-name" "--"))) |
557 0 -1))) | 557 ;; ls-files does not return anything when looking for a |
558 ;; revision of a file that has been renamed or removed. | |
559 (if (string= fn "") | |
560 (file-relative-name file (vc-git-root default-directory)) | |
561 (substring fn 0 -1))))) | |
558 (vc-git-command | 562 (vc-git-command |
559 buffer 0 | 563 buffer 0 |
560 (concat (if rev rev "HEAD") ":" fullname) "cat-file" "blob"))) | 564 nil |
565 "cat-file" "blob" (concat (if rev rev "HEAD") ":" fullname)))) | |
561 | 566 |
562 (defun vc-git-checkout (file &optional editable rev) | 567 (defun vc-git-checkout (file &optional editable rev) |
563 (vc-git-command nil 0 file "checkout" (or rev "HEAD"))) | 568 (vc-git-command nil 0 file "checkout" (or rev "HEAD"))) |
564 | 569 |
565 (defun vc-git-revert (file &optional contents-done) | 570 (defun vc-git-revert (file &optional contents-done) |
687 table (lambda () (vc-git-revision-table files)))) | 692 table (lambda () (vc-git-revision-table files)))) |
688 table)) | 693 table)) |
689 | 694 |
690 (defun vc-git-annotate-command (file buf &optional rev) | 695 (defun vc-git-annotate-command (file buf &optional rev) |
691 (let ((name (file-relative-name file))) | 696 (let ((name (file-relative-name file))) |
692 (vc-git-command buf 'async name "blame" "--date=iso" "-C" "-C" rev))) | 697 (vc-git-command buf 'async nil "blame" "--date=iso" "-C" "-C" rev "--" name))) |
693 | 698 |
694 (declare-function vc-annotate-convert-time "vc-annotate" (time)) | 699 (declare-function vc-annotate-convert-time "vc-annotate" (time)) |
695 | 700 |
696 (defun vc-git-annotate-time () | 701 (defun vc-git-annotate-time () |
697 (and (re-search-forward "[0-9a-f]+[^()]+(.* \\([0-9]+\\)-\\([0-9]+\\)-\\([0-9]+\\) \\([0-9]+\\):\\([0-9]+\\):\\([0-9]+\\) \\([-+0-9]+\\) +[0-9]+) " nil t) | 702 (and (re-search-forward "[0-9a-f]+[^()]+(.* \\([0-9]+\\)-\\([0-9]+\\)-\\([0-9]+\\) \\([0-9]+\\):\\([0-9]+\\):\\([0-9]+\\) \\([-+0-9]+\\) +[0-9]+) " nil t) |
733 ;;; MISCELLANEOUS | 738 ;;; MISCELLANEOUS |
734 | 739 |
735 (defun vc-git-previous-revision (file rev) | 740 (defun vc-git-previous-revision (file rev) |
736 "Git-specific version of `vc-previous-revision'." | 741 "Git-specific version of `vc-previous-revision'." |
737 (if file | 742 (if file |
738 (let* ((default-directory (file-name-directory (expand-file-name file))) | 743 (let* ((fname (file-relative-name file)) |
739 (file (file-name-nondirectory file)) | |
740 (prev-rev (with-temp-buffer | 744 (prev-rev (with-temp-buffer |
741 (and | 745 (and |
742 (vc-git--out-ok "rev-list" "-2" rev "--" file) | 746 (vc-git--out-ok "rev-list" "-2" rev "--" fname) |
743 (goto-char (point-max)) | 747 (goto-char (point-max)) |
744 (bolp) | 748 (bolp) |
745 (zerop (forward-line -1)) | 749 (zerop (forward-line -1)) |
746 (not (bobp)) | 750 (not (bobp)) |
747 (buffer-substring-no-properties | 751 (buffer-substring-no-properties |