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>
Alexandre Julliard committed
Mar 19, 2006 at 10:05 UTC
75a8180d4b6939aca03b2c6320f128469abd5879
1 file changed
+9
-2
contrib/emacs/git.el
+9
-2
@@ -59,14 +59,14 @@
59
60
(defcustom git-committer-name nil
61
"User name to use for commits.
62
-The default is to fall back to `add-log-full-name' and then `user-full-name'."
62
+The default is to fall back to the repository config, then to `add-log-full-name' and then to `user-full-name'."
63
:group 'git
64
:type '(choice (const :tag "Default" nil)
65
(string :tag "Name")))
66
67
(defcustom git-committer-email nil
68
"Email address to use for commits.
69
-The default is to fall back to `add-log-mailing-address' and then `user-mail-address'."
69
+The default is to fall back to the git repository config, then to `add-log-mailing-address' and then to `user-mail-address'."
70
:group 'git
71
:type '(choice (const :tag "Default" nil)
72
(string :tag "Email")))
@@ -203,6 +203,7 @@ The default is to fall back to `add-log-mailing-address' and then `user-mail-add
203
"Return the name to use as GIT_COMMITTER_NAME."
204
; copied from log-edit
205
(or git-committer-name
206
+ (git-repo-config "user.name")
207
(and (boundp 'add-log-full-name) add-log-full-name)
208
(and (fboundp 'user-full-name) (user-full-name))
209
(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
212
"Return the email address to use as GIT_COMMITTER_EMAIL."
213
; copied from log-edit
214
(or git-committer-email
215
+ (git-repo-config "user.email")
216
(and (boundp 'add-log-mailing-address) add-log-mailing-address)
217
(and (fboundp 'user-mail-address) (user-mail-address))
218
(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
270
(git-get-string-sha1
271
(git-call-process-env-string nil "rev-parse" rev)))
272
273
+(defun git-repo-config (key)
274
+ "Retrieve the value associated to KEY in the git repository config file."
275
+ (let ((str (git-call-process-env-string nil "repo-config" key)))
276
+ (and str (car (split-string str "\n")))))
277
+
278
(defun git-symbolic-ref (ref)
279
"Wrapper for the git-symbolic-ref command."
280
(let ((str (git-call-process-env-string nil "symbolic-ref" ref)))