all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
* support for git commit --amend/--signoff
@ 2010-06-11  6:19 Dan Nicolaescu
  2010-06-11  8:09 ` Juri Linkov
  0 siblings, 1 reply; 38+ messages in thread
From: Dan Nicolaescu @ 2010-06-11  6:19 UTC (permalink / raw)
  To: emacs-devel


It would be nice if VC commit would support --amend and --signoff for git.

The patch below adds key bindings to toggle some variables in the log-edit buffer.
(for --amend it also inserts the contents of the last commit message)

Now vc-git-checkin needs to know any of these variables has been set,
so that it can pass the right flags to the git commit command.

Other VC backends might want to implement similar things.

What is the best way to pass custom flags to the vc-checkin command?


=== modified file 'lisp/vc-git.el'
--- lisp/vc-git.el      2010-06-09 05:24:01 +0000
+++ lisp/vc-git.el      2010-06-10 00:00:50 +0000
@@ -550,6 +550,48 @@ or an empty string if none."
 
 (declare-function log-edit-extract-headers "log-edit" (headers string))
 
+(defvar vc-git-log-edit-signoff nil)
+
+(defvar vc-git-log-edit-amend nil)
+
+(defun vc-git-log-edit-toggle-signoff ()
+  (interactive)
+  (setq vc-git-log-edit-signoff (not vc-git-log-edit-signoff)))
+
+(defun vc-git-log-edit-toggle-amend ()
+  (interactive)
+  (unless vc-git-log-edit-amend
+    (vc-git-command (current-buffer) 1 nil
+                        "log" "--max-count=1" "--pretty=format:%s" "HEAD"))
+  (setq vc-git-log-edit-amend (not vc-git-log-edit-amend)))
+
+(defvar vc-git-log-edit-map
+  (let ((map (make-sparse-keymap "Git-Log-Edit"))
+  (menu-map (make-sparse-keymap)))
+
+    ;; FIXME: Are these key bindings OK?
+    (define-key map "\C-c\C-s" 'vc-git-log-edit-toggle-signoff)
+    (define-key map "\C-c\C-m" 'vc-git-log-edit-toggle-amend)
+
+    ;; FIXME: This does not work.  And it would be better if we could
+    ;; add items to the Log-Edit menu.
+    (define-key map [menu-bar vc-git-log-edit] (cons "Git-Log-Edit" menu-map))
+    (define-key menu-map [ts]
+      '(menu-item "Signoff" vc-git-log-edit-toggle-signoff
+                    :help "Toggle signoff"
+                            :button (:toggle . vc-git-log-edit-signoff)))
+    (define-key menu-map [ta]
+      '(menu-item "Amend" vc-git-log-edit-toggle-amend
+                    :help "Toggle amend, insert old log when turning it on"
+                            :button (:toggle . vc-git-log-edit-amend)))
+    map))
+
+(define-derived-mode vc-git-log-edit-mode log-edit-mode "*VC-log*"
+  "Major mode for editing Git log messages.
+It is based on `log-edit-mode', it has Git specific extensions."
+  (make-local-variable 'vc-git-log-edit-signoff)
+  (make-local-variable 'vc-git-log-edit-amend))
+
 (defun vc-git-checkin (files rev comment)
   (let ((coding-system-for-write vc-git-commits-coding-system))
     (apply 'vc-git-command nil 0 files




^ permalink raw reply	[flat|nested] 38+ messages in thread

end of thread, other threads:[~2010-07-01  0:01 UTC | newest]

Thread overview: 38+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2010-06-11  6:19 support for git commit --amend/--signoff Dan Nicolaescu
2010-06-11  8:09 ` Juri Linkov
2010-06-11 13:23   ` Dan Nicolaescu
2010-06-11 14:18     ` Stefan Monnier
2010-06-11 16:14       ` Štěpán Němec
2010-06-11 20:26         ` Stefan Monnier
2010-06-12  2:19           ` Dan Nicolaescu
2010-06-12 19:59             ` Juri Linkov
2010-06-12 20:19             ` Stefan Monnier
2010-06-19  6:38               ` Dan Nicolaescu
2010-06-23  7:17                 ` Stefan Monnier
2010-06-23  7:45                   ` David Kastrup
2010-06-23  9:00                   ` Miles Bader
2010-06-23 18:55                     ` Dan Nicolaescu
2010-06-23 18:45                   ` Dan Nicolaescu
2010-06-23 22:04                     ` Stefan Monnier
2010-06-23 23:23                       ` Dan Nicolaescu
2010-06-24 21:03                         ` Stefan Monnier
2010-06-24 21:18                           ` Dan Nicolaescu
2010-06-24 22:25                             ` Stefan Monnier
2010-06-24 23:14                               ` Dan Nicolaescu
2010-06-25  1:16                                 ` Stefan Monnier
2010-06-25  2:27                                   ` Dan Nicolaescu
2010-06-25 11:44                                     ` Miles Bader
2010-06-26  5:09                                       ` Dan Nicolaescu
2010-07-01  0:01                                         ` Stefan Monnier
2010-06-26 10:11                                       ` David Kastrup
2010-06-28 21:04                                         ` Juri Linkov
2010-06-11 17:34       ` Dan Nicolaescu
2010-06-11 19:27       ` Juri Linkov
2010-06-11 20:16         ` Dan Nicolaescu
2010-06-11 20:38           ` Juri Linkov
2010-06-11 23:48             ` W Dan Meyer
2010-06-12 20:23               ` Juri Linkov
2010-06-12  2:21             ` Dan Nicolaescu
2010-06-11 23:44           ` Thien-Thi Nguyen
2010-06-12 20:15           ` Stefan Monnier
2010-06-11 20:35         ` Stefan Monnier

Code repositories for project(s) associated with this external index

	https://git.savannah.gnu.org/cgit/emacs.git
	https://git.savannah.gnu.org/cgit/emacs/org-mode.git

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.