diff options
| author | Tom Tromey <tromey@redhat.com> | 2012-12-17 07:56:22 -0700 |
|---|---|---|
| committer | Tom Tromey <tromey@redhat.com> | 2012-12-17 07:56:22 -0700 |
| commit | 3d6eced1ae51ffd0a782130e7c334052277e2724 (patch) | |
| tree | 5d1d2ad7cd3374f922886c4a72062511a035c168 /lisp/vc/vc-git.el | |
| parent | bf69f522a9e135f9aa483cedd53e71e915f2bf75 (diff) | |
| parent | 7c3d167f48d6262ee4e5512aa50a07ee96bc1509 (diff) | |
| download | emacs-3d6eced1ae51ffd0a782130e7c334052277e2724.tar.gz | |
merge from trunk
Diffstat (limited to 'lisp/vc/vc-git.el')
| -rw-r--r-- | lisp/vc/vc-git.el | 52 |
1 files changed, 44 insertions, 8 deletions
diff --git a/lisp/vc/vc-git.el b/lisp/vc/vc-git.el index b48ea1afd95..08b48fa7b40 100644 --- a/lisp/vc/vc-git.el +++ b/lisp/vc/vc-git.el @@ -31,7 +31,7 @@ ;; To install: put this file on the load-path and add Git to the list ;; of supported backends in `vc-handled-backends'; the following line, -;; placed in your ~/.emacs, will accomplish this: +;; placed in your init file, will accomplish this: ;; ;; (add-to-list 'vc-handled-backends 'Git) @@ -608,16 +608,52 @@ The car of the list is the current branch." (defun vc-git-unregister (file) (vc-git-command nil 0 file "rm" "-f" "--cached" "--")) +(declare-function log-edit-mode "log-edit" ()) +(declare-function log-edit-toggle-header "log-edit" (header value)) (declare-function log-edit-extract-headers "log-edit" (headers string)) +(defun vc-git-log-edit-toggle-signoff () + "Toggle whether to add the \"Signed-off-by\" line at the end of +the commit message." + (interactive) + (log-edit-toggle-header "Sign-Off" "yes")) + +(defun vc-git-log-edit-toggle-amend () + "Toggle whether this will amend the previous commit. +If toggling on, also insert its message into the buffer." + (interactive) + (when (log-edit-toggle-header "Amend" "yes") + (goto-char (point-max)) + (unless (bolp) (insert "\n")) + (insert (with-output-to-string + (vc-git-command + standard-output 1 nil + "log" "--max-count=1" "--pretty=format:%B" "HEAD"))))) + +(defvar vc-git-log-edit-mode-map + (let ((map (make-sparse-keymap "Git-Log-Edit"))) + (define-key map "\C-c\C-s" 'vc-git-log-edit-toggle-signoff) + (define-key map "\C-c\C-e" 'vc-git-log-edit-toggle-amend) + map)) + +(define-derived-mode vc-git-log-edit-mode log-edit-mode "Log-Edit/git" + "Major mode for editing Git log messages. +It is based on `log-edit-mode', and has Git-specific extensions.") + (defun vc-git-checkin (files _rev comment) (let ((coding-system-for-write vc-git-commits-coding-system)) - (apply 'vc-git-command nil 0 files - (nconc (list "commit" "-m") - (log-edit-extract-headers '(("Author" . "--author") - ("Date" . "--date")) - comment) - (list "--only" "--"))))) + (cl-flet ((boolean-arg-fn + (argument) + (lambda (value) (when (equal value "yes") (list argument))))) + (apply 'vc-git-command nil 0 files + (nconc (list "commit" "-m") + (log-edit-extract-headers + `(("Author" . "--author") + ("Date" . "--date") + ("Amend" . ,(boolean-arg-fn "--amend")) + ("Sign-Off" . ,(boolean-arg-fn "--signoff"))) + comment) + (list "--only" "--")))))) (defun vc-git-find-revision (file rev buffer) (let* (process-file-side-effects @@ -1112,7 +1148,7 @@ This command shares argument histories with \\[rgrep] and \\[grep]." The difference to vc-do-command is that this function always invokes `vc-git-program'." (apply 'vc-do-command (or buffer "*vc*") okstatus vc-git-program - file-or-list flags)) + file-or-list (cons "--no-pager" flags))) (defun vc-git--empty-db-p () "Check if the git db is empty (no commit done yet)." |
