aboutsummaryrefslogtreecommitdiffstats
path: root/contrib/emacs/git.el
diff options
context:
space:
mode:
authorAlexandre Julliard <julliard@winehq.org>2006-03-19 10:05:48 +0100
committerJunio C Hamano <junkio@cox.net>2006-03-19 12:30:07 -0800
commit75a8180d4b6939aca03b2c6320f128469abd5879 (patch)
tree46c83eee61d11b49590c407a76ab9c74daba8f64 /contrib/emacs/git.el
parent9de83169d34825d617b7fe92b95c966d9910848d (diff)
downloadgit-75a8180d4b6939aca03b2c6320f128469abd5879.tar.gz
git.el: Get the default user name and email from the repository config.
If user name or email are not set explicitly, get them from the user.name and user.email configuration values before falling back to the Emacs defaults. Signed-off-by: Alexandre Julliard <julliard@winehq.org> Signed-off-by: Junio C Hamano <junkio@cox.net>
Diffstat (limited to 'contrib/emacs/git.el')
-rw-r--r--contrib/emacs/git.el11
1 files changed, 9 insertions, 2 deletions
diff --git a/contrib/emacs/git.el b/contrib/emacs/git.el
index cf650da3e5..5496a1bb5e 100644
--- a/contrib/emacs/git.el
+++ b/contrib/emacs/git.el
@@ -59,14 +59,14 @@
(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'."
+The default is to fall back to the repository config, then to `add-log-full-name' and then to `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'."
+The default is to fall back to the git repository config, then to `add-log-mailing-address' and then to `user-mail-address'."
:group 'git
:type '(choice (const :tag "Default" nil)
(string :tag "Email")))
@@ -203,6 +203,7 @@ The default is to fall back to `add-log-mailing-address' and then `user-mail-add
"Return the name to use as GIT_COMMITTER_NAME."
; copied from log-edit
(or git-committer-name
+ (git-repo-config "user.name")
(and (boundp 'add-log-full-name) add-log-full-name)
(and (fboundp 'user-full-name) (user-full-name))
(and (boundp 'user-full-name) user-full-name)))
@@ -211,6 +212,7 @@ The default is to fall back to `add-log-mailing-address' and then `user-mail-add
"Return the email address to use as GIT_COMMITTER_EMAIL."
; copied from log-edit
(or git-committer-email
+ (git-repo-config "user.email")
(and (boundp 'add-log-mailing-address) add-log-mailing-address)
(and (fboundp 'user-mail-address) (user-mail-address))
(and (boundp 'user-mail-address) user-mail-address)))
@@ -268,6 +270,11 @@ The default is to fall back to `add-log-mailing-address' and then `user-mail-add
(git-get-string-sha1
(git-call-process-env-string nil "rev-parse" rev)))
+(defun git-repo-config (key)
+ "Retrieve the value associated to KEY in the git repository config file."
+ (let ((str (git-call-process-env-string nil "repo-config" key)))
+ (and str (car (split-string str "\n")))))
+
(defun git-symbolic-ref (ref)
"Wrapper for the git-symbolic-ref command."
(let ((str (git-call-process-env-string nil "symbolic-ref" ref)))