# HG changeset patch # User Dan Nicolaescu # Date 1270827330 25200 # Node ID 2c6eaa7826c734385d629c4d374a83a893fb4829 # Parent 03ef65bf2e25edcb7a7ca4daca583f607a391a5c 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. diff -r 03ef65bf2e25 -r 2c6eaa7826c7 etc/NEWS --- a/etc/NEWS Fri Apr 09 10:17:52 2010 -0400 +++ b/etc/NEWS Fri Apr 09 08:35:30 2010 -0700 @@ -107,6 +107,10 @@ 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. diff -r 03ef65bf2e25 -r 2c6eaa7826c7 lisp/ChangeLog --- a/lisp/ChangeLog Fri Apr 09 10:17:52 2010 -0400 +++ b/lisp/ChangeLog Fri Apr 09 08:35:30 2010 -0700 @@ -1,3 +1,11 @@ +2010-04-09 Dan Nicolaescu + + 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 * vc-hooks.el, vc-git.el: Improve documentation comments. diff -r 03ef65bf2e25 -r 2c6eaa7826c7 lisp/vc-git.el --- a/lisp/vc-git.el Fri Apr 09 10:17:52 2010 -0400 +++ b/lisp/vc-git.el Fri Apr 09 08:35:30 2010 -0700 @@ -548,10 +548,10 @@ (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 @@ (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" "--"))