diff options
Diffstat (limited to 'lisp/vc-git.el')
| -rw-r--r-- | lisp/vc-git.el | 58 |
1 files changed, 46 insertions, 12 deletions
diff --git a/lisp/vc-git.el b/lisp/vc-git.el index 24062a0f4f6..4383e609adb 100644 --- a/lisp/vc-git.el +++ b/lisp/vc-git.el | |||
| @@ -118,7 +118,7 @@ If nil, use the value of `vc-diff-switches'. If t, use no switches." | |||
| 118 | :version "23.1" | 118 | :version "23.1" |
| 119 | :group 'vc) | 119 | :group 'vc) |
| 120 | 120 | ||
| 121 | (defvar git-commits-coding-system 'utf-8 | 121 | (defvar vc-git-commits-coding-system 'utf-8 |
| 122 | "Default coding system for git commits.") | 122 | "Default coding system for git commits.") |
| 123 | 123 | ||
| 124 | ;;; BACKEND PROPERTIES | 124 | ;;; BACKEND PROPERTIES |
| @@ -171,7 +171,14 @@ If nil, use the value of `vc-diff-switches'. If t, use no switches." | |||
| 171 | 171 | ||
| 172 | (defun vc-git-state (file) | 172 | (defun vc-git-state (file) |
| 173 | "Git-specific version of `vc-state'." | 173 | "Git-specific version of `vc-state'." |
| 174 | ;; FIXME: This can't set 'ignored yet | 174 | ;; FIXME: This can't set 'ignored or 'conflict yet |
| 175 | ;; The 'ignored state could be detected with `git ls-files -i -o | ||
| 176 | ;; --exclude-standard` It also can't set 'needs-update or | ||
| 177 | ;; 'needs-merge. The rough equivalent would be that upstream branch | ||
| 178 | ;; for current branch is in fast-forward state i.e. current branch | ||
| 179 | ;; is direct ancestor of corresponding upstream branch, and the file | ||
| 180 | ;; was modified upstream. But we can't check that without a network | ||
| 181 | ;; operation. | ||
| 175 | (if (not (vc-git-registered file)) | 182 | (if (not (vc-git-registered file)) |
| 176 | 'unregistered | 183 | 'unregistered |
| 177 | (vc-git--call nil "add" "--refresh" "--" (file-relative-name file)) | 184 | (vc-git--call nil "add" "--refresh" "--" (file-relative-name file)) |
| @@ -541,11 +548,16 @@ or an empty string if none." | |||
| 541 | (defun vc-git-unregister (file) | 548 | (defun vc-git-unregister (file) |
| 542 | (vc-git-command nil 0 file "rm" "-f" "--cached" "--")) | 549 | (vc-git-command nil 0 file "rm" "-f" "--cached" "--")) |
| 543 | 550 | ||
| 551 | (declare-function log-edit-extract-headers "log-edit" (headers string)) | ||
| 544 | 552 | ||
| 545 | (defun vc-git-checkin (files rev comment) | 553 | (defun vc-git-checkin (files rev comment) |
| 546 | (let ((coding-system-for-write git-commits-coding-system)) | 554 | (let ((coding-system-for-write vc-git-commits-coding-system)) |
| 547 | (vc-git-command nil 0 files "commit" | 555 | (apply 'vc-git-command nil 0 files |
| 548 | "-m" comment "--only" "--"))) | 556 | (nconc (list "commit" "-m") |
| 557 | (log-edit-extract-headers '(("Author" . "--author") | ||
| 558 | ("Date" . "--date")) | ||
| 559 | comment) | ||
| 560 | (list "--only" "--"))))) | ||
| 549 | 561 | ||
| 550 | (defun vc-git-find-revision (file rev buffer) | 562 | (defun vc-git-find-revision (file rev buffer) |
| 551 | (let* (process-file-side-effects | 563 | (let* (process-file-side-effects |
| @@ -580,7 +592,7 @@ or an empty string if none." | |||
| 580 | "Get change log associated with FILES. | 592 | "Get change log associated with FILES. |
| 581 | Note that using SHORTLOG requires at least Git version 1.5.6, | 593 | Note that using SHORTLOG requires at least Git version 1.5.6, |
| 582 | for the --graph option." | 594 | for the --graph option." |
| 583 | (let ((coding-system-for-read git-commits-coding-system)) | 595 | (let ((coding-system-for-read vc-git-commits-coding-system)) |
| 584 | ;; `vc-do-command' creates the buffer, but we need it before running | 596 | ;; `vc-do-command' creates the buffer, but we need it before running |
| 585 | ;; the command. | 597 | ;; the command. |
| 586 | (vc-setup-buffer buffer) | 598 | (vc-setup-buffer buffer) |
| @@ -600,25 +612,46 @@ for the --graph option." | |||
| 600 | (when start-revision (list start-revision)) | 612 | (when start-revision (list start-revision)) |
| 601 | '("--"))))))) | 613 | '("--"))))))) |
| 602 | 614 | ||
| 615 | (defun vc-git-log-outgoing (buffer remote-location) | ||
| 616 | (interactive) | ||
| 617 | (vc-git-command | ||
| 618 | buffer 0 nil | ||
| 619 | "log" | ||
| 620 | "--no-color" "--graph" "--decorate" "--date=short" | ||
| 621 | "--pretty=tformat:%d%h %ad %s" "--abbrev-commit" | ||
| 622 | (concat (if (string= remote-location "") | ||
| 623 | "@{upstream}" | ||
| 624 | remote-location) | ||
| 625 | "..HEAD"))) | ||
| 626 | |||
| 627 | (defun vc-git-log-incoming (buffer remote-location) | ||
| 628 | (interactive) | ||
| 629 | (vc-git-command nil 0 nil "fetch") | ||
| 630 | (vc-git-command | ||
| 631 | buffer 0 nil | ||
| 632 | "log" | ||
| 633 | "--no-color" "--graph" "--decorate" "--date=short" | ||
| 634 | "--pretty=tformat:%d%h %ad %s" "--abbrev-commit" | ||
| 635 | (concat "HEAD.." (if (string= remote-location "") | ||
| 636 | "@{upstream}" | ||
| 637 | remote-location)))) | ||
| 638 | |||
| 603 | (defvar log-view-message-re) | 639 | (defvar log-view-message-re) |
| 604 | (defvar log-view-file-re) | 640 | (defvar log-view-file-re) |
| 605 | (defvar log-view-font-lock-keywords) | 641 | (defvar log-view-font-lock-keywords) |
| 606 | (defvar log-view-per-file-logs) | 642 | (defvar log-view-per-file-logs) |
| 607 | 643 | ||
| 608 | ;; Dynamically bound. | ||
| 609 | (defvar vc-short-log) | ||
| 610 | |||
| 611 | (define-derived-mode vc-git-log-view-mode log-view-mode "Git-Log-View" | 644 | (define-derived-mode vc-git-log-view-mode log-view-mode "Git-Log-View" |
| 612 | (require 'add-log) ;; We need the faces add-log. | 645 | (require 'add-log) ;; We need the faces add-log. |
| 613 | ;; Don't have file markers, so use impossible regexp. | 646 | ;; Don't have file markers, so use impossible regexp. |
| 614 | (set (make-local-variable 'log-view-file-re) "\\`a\\`") | 647 | (set (make-local-variable 'log-view-file-re) "\\`a\\`") |
| 615 | (set (make-local-variable 'log-view-per-file-logs) nil) | 648 | (set (make-local-variable 'log-view-per-file-logs) nil) |
| 616 | (set (make-local-variable 'log-view-message-re) | 649 | (set (make-local-variable 'log-view-message-re) |
| 617 | (if vc-short-log | 650 | (if (not (eq vc-log-view-type 'long)) |
| 618 | "^\\(?:[*/\\| ]+ \\)?\\(?: ([^)]+)\\)?\\([0-9a-z]+\\) \\([-a-z0-9]+\\) \\(.*\\)" | 651 | "^\\(?:[*/\\| ]+ \\)?\\(?: ([^)]+)\\)?\\([0-9a-z]+\\) \\([-a-z0-9]+\\) \\(.*\\)" |
| 619 | "^commit *\\([0-9a-z]+\\)")) | 652 | "^commit *\\([0-9a-z]+\\)")) |
| 620 | (set (make-local-variable 'log-view-font-lock-keywords) | 653 | (set (make-local-variable 'log-view-font-lock-keywords) |
| 621 | (if vc-short-log | 654 | (if (not (eq vc-log-view-type 'long)) |
| 622 | '( | 655 | '( |
| 623 | ;; Same as log-view-message-re, except that we don't | 656 | ;; Same as log-view-message-re, except that we don't |
| 624 | ;; want the shy group for the tag name. | 657 | ;; want the shy group for the tag name. |
| @@ -681,7 +714,8 @@ or BRANCH^ (where \"^\" can be repeated)." | |||
| 681 | (with-temp-buffer | 714 | (with-temp-buffer |
| 682 | (vc-git-command t nil nil "for-each-ref" "--format=%(refname)") | 715 | (vc-git-command t nil nil "for-each-ref" "--format=%(refname)") |
| 683 | (goto-char (point-min)) | 716 | (goto-char (point-min)) |
| 684 | (while (re-search-forward "^refs/\\(heads\\|tags\\)/\\(.*\\)$" nil t) | 717 | (while (re-search-forward "^refs/\\(heads\\|tags\\|remotes\\)/\\(.*\\)$" |
| 718 | nil t) | ||
| 685 | (push (match-string 2) table))) | 719 | (push (match-string 2) table))) |
| 686 | table)) | 720 | table)) |
| 687 | 721 | ||