threads / patch / 8899

patchPrefer $EMAIL over auto-generated user@hostname.

Subject: [PATCH] Prefer $EMAIL over auto-generated user@hostname.

## tl;dr

One message between Jul 6, 2007 and Jul 6, 2007. Diffs are folded; open one to read it.

replies: 0people: 1as markdown or json

Brandon Casey· Jul 6, 2007, 16:14 UTC · lore

This makes $EMAIL the second to last resort ahead of username@hostname rather than the last resort when GIT_AUTHOR_EMAIL or GIT_COMMITER_EMAIL and user.email are not set.

Signed-off-by: Brandon Casey <casey@nrlssc.navy.mil>
---
Alex Riesen wrote:
Show 8 quoted lines
> On 7/6/07, Brandon Casey <casey@nrlssc.navy.mil> wrote:
>>
>> Is the recommended tab stop 8 characters as it is for linux? or 4?
>>
> 
> Tab is always 8 spaces. It is indentation which can be 8, 4, 3, 2, and
> even 1.
> It is 8 in Git.
Here's an updated patch using tabs.
-brandon
 ident.c |    6 ++++--
 1 files changed, 4 insertions(+), 2 deletions(-)
Show changes to ident.c +4 −2
diff --git a/ident.c b/ident.c
index 3d49608..be5efcd 100644
--- a/ident.c
+++ b/ident.c
@@ -73,6 +73,7 @@ static void copy_email(const struct passwd *pw)
 static void setup_ident(void)
 {
 	struct passwd *pw = NULL;
+	char *email;
 
 	/* Get the name ("gecos") */
 	if (!git_default_name[0]) {
@@ -82,6 +83,9 @@ static void setup_ident(void)
 		copy_gecos(pw, git_default_name, sizeof(git_default_name));
 	}
 
+	if (!git_default_email[0] && (email = getenv("EMAIL")) != NULL)
+		strlcpy(git_default_email, email, sizeof(git_default_email));
+
 	if (!git_default_email[0]) {
 		if (!pw)
 			pw = getpwuid(getuid());
@@ -197,8 +201,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.3.rc0.30.g114f-dirty

← back to recent threads