diff --git a/contrib/emacs/git.el b/contrib/emacs/git.el
index 335dcb2d4a5c3a5ec481f2ac54103bf24e49ca78..5135e361be46af0b4ffce03fc8582a7a6ad25970 100644 (file)
--- a/contrib/emacs/git.el
+++ b/contrib/emacs/git.el
;; - hook into file save (after-save-hook)
;; - diff against other branch
;; - renaming files from the status buffer
-;; - support for appending signed-off-by
;; - creating tags
;; - fetch/pull
;; - switching branches
;; - revlist browser
;; - git-show-branch browser
-;; - customize support
;; - menus
;;
(require 'ewoc)
-;;;; Faces
+;;;; Customizations
;;;; ------------------------------------------------------------
+(defgroup git nil
+ "Git user interface")
+
+(defcustom git-committer-name nil
+ "User name to use for commits.
+The default is to fall back to `add-log-full-name' and then `user-full-name'."
+ :group 'git
+ :type '(choice (const :tag "Default" nil)
+ (string :tag "Name")))
+
+(defcustom git-committer-email nil
+ "Email address to use for commits.
+The default is to fall back to `add-log-mailing-address' and then `user-mail-address'."
+ :group 'git
+ :type '(choice (const :tag "Default" nil)
+ (string :tag "Email")))
+
+(defcustom git-commits-coding-system 'utf-8
+ "Default coding system for the log message of git commits."
+ :group 'git
+ :type 'coding-system)
+
+(defcustom git-append-signed-off-by nil
+ "Whether to append a Signed-off-by line to the commit message before editing."
+ :group 'git
+ :type 'boolean)
+
+(defcustom git-per-dir-ignore-file ".gitignore"
+ "Name of the per-directory ignore file."
+ :group 'git
+ :type 'string)
+
(defface git-status-face
'((((class color) (background light)) (:foreground "purple")))
- "Git mode face used to highlight added and modified files.")
+ "Git mode face used to highlight added and modified files."
+ :group 'git)
(defface git-unmerged-face
'((((class color) (background light)) (:foreground "red" :bold t)))
- "Git mode face used to highlight unmerged files.")
+ "Git mode face used to highlight unmerged files."
+ :group 'git)
(defface git-unknown-face
'((((class color) (background light)) (:foreground "goldenrod" :bold t)))
- "Git mode face used to highlight unknown files.")
+ "Git mode face used to highlight unknown files."
+ :group 'git)
(defface git-uptodate-face
'((((class color) (background light)) (:foreground "grey60")))
- "Git mode face used to highlight up-to-date files.")
+ "Git mode face used to highlight up-to-date files."
+ :group 'git)
(defface git-ignored-face
'((((class color) (background light)) (:foreground "grey60")))
- "Git mode face used to highlight ignored files.")
+ "Git mode face used to highlight ignored files."
+ :group 'git)
(defface git-mark-face
'((((class color) (background light)) (:foreground "red" :bold t)))
- "Git mode face used for the file marks.")
+ "Git mode face used for the file marks."
+ :group 'git)
(defface git-header-face
'((((class color) (background light)) (:foreground "blue")))
- "Git mode face used for commit headers.")
+ "Git mode face used for commit headers."
+ :group 'git)
(defface git-separator-face
'((((class color) (background light)) (:foreground "brown")))
- "Git mode face used for commit separator.")
+ "Git mode face used for commit separator."
+ :group 'git)
(defface git-permission-face
'((((class color) (background light)) (:foreground "green" :bold t)))
- "Git mode face used for permission changes.")
-
-(defvar git-committer-name nil
- "*User name to use for commits.
-If not set, fall back to `add-log-full-name' and then `user-full-name'.")
-
-(defvar git-committer-email nil
- "*Email address to use for commits.
-If not set, fall back to `add-log-mailing-address' and then `user-mail-address'.")
-
-(defvar git-commits-coding-system 'utf-8
- "Default coding system for git commits.")
-
-(defconst git-log-msg-separator "--- log message follows this line ---")
-
-(defconst git-per-dir-ignore-file ".gitignore"
- "Name of the per-directory ignore file.")
+ "Git mode face used for permission changes."
+ :group 'git)
;;;; Utilities
;;;; ------------------------------------------------------------
+(defconst git-log-msg-separator "--- log message follows this line ---")
+
(defun git-get-env-strings (env)
"Build a list of NAME=VALUE strings from a list of environment strings."
(mapcar (lambda (entry) (concat (car entry) "=" (cdr entry))) env))
@@ -277,7 +302,7 @@ If not set, fall back to `add-log-mailing-address' and then `user-mail-address'.
(with-current-buffer buffer
(goto-char (point-min))
(if
- (setq log-start (re-search-forward (concat "^" git-log-msg-separator "\n") nil t))
+ (setq log-start (re-search-forward (concat "^" (regexp-quote git-log-msg-separator) "\n") nil t))
(save-restriction
(narrow-to-region (point-min) log-start)
(goto-char (point-min))
@@ -792,7 +817,8 @@ If not set, fall back to `add-log-mailing-address' and then `user-mail-address'.
(unless git-status (error "Not in git-status buffer."))
(let ((buffer (get-buffer-create "*git-commit*"))
(merge-heads (git-get-merge-heads))
- (dir default-directory))
+ (dir default-directory)
+ (sign-off git-append-signed-off-by))
(with-current-buffer buffer
(when (eq 0 (buffer-size))
(cd dir)
@@ -809,10 +835,13 @@ If not set, fall back to `add-log-mailing-address' and then `user-mail-address'.
'face 'git-header-face)
(propertize git-log-msg-separator 'face 'git-separator-face)
"\n")
- (when (and merge-heads (file-readable-p ".git/MERGE_MSG"))
- (insert-file-contents ".git/MERGE_MSG"))))
+ (cond ((and merge-heads (file-readable-p ".git/MERGE_MSG"))
+ (insert-file-contents ".git/MERGE_MSG"))
+ (sign-off
+ (insert (format "\n\nSigned-off-by: %s <%s>\n"
+ (git-get-committer-name) (git-get-committer-email)))))))
(let ((log-edit-font-lock-keywords
- `(("^\\(Author:\\|Date:\\|Parent:\\)\\(.*\\)"
+ `(("^\\(Author:\\|Date:\\|Parent:\\|Signed-off-by:\\)\\(.*\\)"
(1 font-lock-keyword-face)
(2 font-lock-function-name-face))
(,(concat "^\\(" (regexp-quote git-log-msg-separator) "\\)$")