Add --author support to git commit.
authorDan Nicolaescu <dann@ics.uci.edu>
Fri, 9 Apr 2010 15:35:30 +0000 (08:35 -0700)
committerDan Nicolaescu <dann@ics.uci.edu>
Fri, 9 Apr 2010 15:35:30 +0000 (08:35 -0700)
* vc-git.el (vc-git-checkin): Pass extra-args to the commit command.
(vc-git-log-edit-mode): New minor mode.
(log-edit-mode, log-edit-extra-flags, log-edit-mode): New
declarations.

etc/NEWS
lisp/ChangeLog
lisp/vc-git.el

index a21f7967c2f1cb5e9ab61eff4746ee2064ab2484..dadb92e0248c3b20295d5b44b2dc407ead9d068a 100644 (file)
--- a/etc/NEWS
+++ b/etc/NEWS
@@ -107,6 +107,10 @@ choose a color via list-colors-display.
 Author: NAME
 line will add "--author NAME" to the "bzr commit" command.
 
+**** For Git, adding an
+Author: NAME
+line will add "--author NAME" to the "git commit" command.
+
 **** For Hg, adding an
 Author: NAME
 line will add "--user NAME" to the "hg commit" command.
index 029db96d3ab6962e4226991ae225133e0da87b73..f4091aca9f4811a842d878f681ade825d93e425f 100644 (file)
@@ -1,3 +1,11 @@
+2010-04-09  Dan Nicolaescu  <dann@ics.uci.edu>
+
+       Add --author support to git commit.
+       * vc-git.el (vc-git-checkin): Pass extra-args to the commit command.
+       (vc-git-log-edit-mode): New minor mode.
+       (log-edit-mode, log-edit-extra-flags, log-edit-mode): New
+       declarations.
+
 2010-04-09  Eric Raymond  <esr@snark.thyrsus.com>
 
        * vc-hooks.el, vc-git.el: Improve documentation comments.
index c1ca48a5b788dd1b347a6506ffdcad8bef61bf71..6010aa20b35d6edfd186f46330b309b04bf351ec 100644 (file)
@@ -548,10 +548,10 @@ or an empty string if none."
   (vc-git-command nil 0 file "rm" "-f" "--cached" "--"))
 
 
-(defun vc-git-checkin (files rev comment  &optional extra-args-ignored)
+(defun vc-git-checkin (files rev comment  &optional extra-args)
   (let ((coding-system-for-write git-commits-coding-system))
-    (vc-git-command nil 0 files "commit"
-                   "-m" comment "--only" "--")))
+    (apply 'vc-git-command nil 0 files
+          (nconc (list "commit" "-m" comment) extra-args (list "--only" "--")))))
 
 (defun vc-git-find-revision (file rev buffer)
   (let* (process-file-side-effects
@@ -790,6 +790,21 @@ or BRANCH^ (where \"^\" can be repeated)."
                    (progn (forward-line 1) (1- (point)))))))))
     (or (vc-git-symbolic-commit next-rev) next-rev)))
 
+(declare-function log-edit-mode "log-edit" ())
+(defvar log-edit-extra-flags)
+(defvar log-edit-before-checkin-process)
+
+(define-derived-mode vc-git-log-edit-mode log-edit-mode "Git-log-edit"
+  "Mode for editing Git commit logs.
+If a line like:
+Author: NAME
+is present in the log, it is removed, and
+--author=NAME
+is passed to the git commit command."
+  (set (make-local-variable 'log-edit-extra-flags) nil)
+  (set (make-local-variable 'log-edit-before-checkin-process)
+       '(("^Author:[ \t]+\\(.*\\)[ \t]*$" . (list "--author" (match-string 1))))))
+
 (defun vc-git-delete-file (file)
   (vc-git-command nil 0 file "rm" "-f" "--"))