git.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] Prefer EMAIL to username@hostname.
@ 2007-07-06  0:29 Matt Kraai
  0 siblings, 0 replies; only message in thread
From: Matt Kraai @ 2007-07-06  0:29 UTC (permalink / raw)
  To: git; +Cc: Matt Kraai

Signed-off-by: Matt Kraai <kraai@ftbfs.org>
---
 ident.c |   19 ++++++++++++-------
 1 files changed, 12 insertions(+), 7 deletions(-)

diff --git a/ident.c b/ident.c
index 3d49608..6612d17 100644
--- a/ident.c
+++ b/ident.c
@@ -83,11 +83,18 @@ static void setup_ident(void)
 	}
 
 	if (!git_default_email[0]) {
-		if (!pw)
-			pw = getpwuid(getuid());
-		if (!pw)
-			die("You don't exist. Go away!");
-		copy_email(pw);
+		const char *email = getenv("EMAIL");
+
+		if (email && email[0])
+			strlcpy(git_default_email, email,
+				sizeof(git_default_email));
+		else {
+			if (!pw)
+				pw = getpwuid(getuid());
+			if (!pw)
+				die("You don't exist. Go away!");
+			copy_email(pw);
+		}
 	}
 
 	/* And set the default date */
@@ -197,8 +204,6 @@ const char *fmt_ident(const char *name, const char *email,
 		name = git_default_name;
 	if (!email)
 		email = git_default_email;
-	if (!email)
-		email = getenv("EMAIL");
 
 	if (!*name) {
 		struct passwd *pw;
-- 
1.5.2.3

^ permalink raw reply related	[flat|nested] only message in thread

only message in thread, other threads:[~2007-07-06  0:29 UTC | newest]

Thread overview: (only message) (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2007-07-06  0:29 [PATCH] Prefer EMAIL to username@hostname Matt Kraai

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).