git.el: Added support for Signed-off-by.
If `git-append-signed-off-by' is non-nil, automatically append a sign-off line to the log message when editing it. Signed-off-by: Alexandre Julliard <julliard@winehq.org> Signed-off-by: Junio C Hamano <junkio@cox.net>
Alexandre Julliard committed
Mar 4, 2006 at 17:38 UTC
45033ad9e333a8c89e7fe3d6bf75adef043602e7
1 file changed
+11
-5
contrib/emacs/git.el
+11
-5
@@ -39,7 +39,6 @@
39
;; - hook into file save (after-save-hook)
40
;; - diff against other branch
41
;; - renaming files from the status buffer
42
-;; - support for appending signed-off-by
42
;; - creating tags
43
;; - fetch/pull
44
;; - switching branches
@@ -103,6 +102,9 @@ If not set, fall back to `add-log-mailing-address' and then `user-mail-address'.
102
(defvar git-commits-coding-system 'utf-8
103
"Default coding system for git commits.")
104
105
+(defvar git-append-signed-off-by nil
106
+ "Whether to append a Signed-off-by line to the commit message.")
107
+
108
(defconst git-log-msg-separator "--- log message follows this line ---")
109
110
(defconst git-per-dir-ignore-file ".gitignore"
@@ -792,7 +794,8 @@ If not set, fall back to `add-log-mailing-address' and then `user-mail-address'.
794
(unless git-status (error "Not in git-status buffer."))
795
(let ((buffer (get-buffer-create "*git-commit*"))
796
(merge-heads (git-get-merge-heads))
795
- (dir default-directory))
797
+ (dir default-directory)
798
+ (sign-off git-append-signed-off-by))
799
(with-current-buffer buffer
800
(when (eq 0 (buffer-size))
801
(cd dir)
@@ -809,10 +812,13 @@ If not set, fall back to `add-log-mailing-address' and then `user-mail-address'.
812
'face 'git-header-face)
813
(propertize git-log-msg-separator 'face 'git-separator-face)
814
"\n")
812
- (when (and merge-heads (file-readable-p ".git/MERGE_MSG"))
813
- (insert-file-contents ".git/MERGE_MSG"))))
815
+ (cond ((and merge-heads (file-readable-p ".git/MERGE_MSG"))
816
+ (insert-file-contents ".git/MERGE_MSG"))
817
+ (sign-off
818
+ (insert (format "\n\nSigned-off-by: %s <%s>\n"
819
+ (git-get-committer-name) (git-get-committer-email)))))))
820
(let ((log-edit-font-lock-keywords
815
- `(("^\\(Author:\\|Date:\\|Parent:\\)\\(.*\\)"
821
+ `(("^\\(Author:\\|Date:\\|Parent:\\|Signed-off-by:\\)\\(.*\\)"
822
(1 font-lock-keyword-face)
823
(2 font-lock-function-name-face))
824
(,(concat "^\\(" (regexp-quote git-log-msg-separator) "\\)$")