Skip to contentSkip to conversation

Prefer $EMAIL over auto-generated user@hostname.

PATCH In review Brandon Casey 5 participants 10 messages Jun 15, 2016

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 Prefer $EMAIL over auto-generated user@hostname.

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.

---

Quoted 2 lines · Linus Torvalds

If you want it to prefer $EMAIL, you'd need to change the initialization of git_default_email, methinks.

How about this?

 ident.c |    6 ++++--
 1 files changed, 4 insertions(+), 2 deletions(-)
ident.c +4 -2
index 3d49608..dc13510 100644
@@ -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;
Signature · 1 line
1.5.3.rc0.30.g114f-dirty
#1 lore raw

Hello Brandon,

ident.c static void copy_email(const struct passwd *pw) · line 76

Quoted 2 lines · Brandon Casey
ident.c +1 -0
 	struct passwd *pw = NULL;
+        char *email;

Indention error. Otherwise it looks good (just from reading the patch).

Best regards
Uwe

Signature · 4 lines
Uwe Kleine-König

Set the I_WANT_A_BROKEN_PS environment variable to force BSD syntax ...
	-- manpage of procps
#2 lore raw
Quoted 6 lines · Uwe Kleine-König

Hello Brandon,

ident.c static void copy_email(const struct passwd *pw) · line 76

Quoted 2 lines · Brandon Casey
ident.c +1 -0
 	struct passwd *pw = NULL;
+        char *email;

Indention error. Otherwise it looks good (just from reading the patch).

huh. It doesn't look like that in my mail reader.
I have
struct passwd...
+ char *email;

and the patch applied cleanly when I saved the email and applied it using git-am

cat git_email.patch | git-am

-brandon

#3 lore raw

Hi,

Quoted 13 lines · Brandon Casey
Quoted 6 lines · Uwe Kleine-K?nig

Hello Brandon,

ident.c static void copy_email(const struct passwd *pw) · line 76

Quoted 2 lines · Brandon Casey
ident.c +1 -0
 	struct passwd *pw = NULL;
+        char *email;

Indention error. Otherwise it looks good (just from reading the patch).

huh. It doesn't look like that in my mail reader.
I have
struct passwd...
+ char *email;

Quoted 4 lines

and the patch applied cleanly when I saved the email and applied it using git-am

cat git_email.patch | git-am

Yes, it applies cleanly. But it has 8 spaces before "char *email", not a tab (otherwise it would be lined up with "struct passwd").

Hth,
Dscho

#4 lore raw
Quoted 16 lines · Johannes Schindelin

Hi,

Quoted 12 lines · Brandon Casey
Quoted 6 lines · Uwe Kleine-K?nig

Hello Brandon,

ident.c static void copy_email(const struct passwd *pw) · line 76

Quoted 2 lines · Brandon Casey
ident.c +1 -0
 	struct passwd *pw = NULL;
+        char *email;

Indention error. Otherwise it looks good (just from reading the patch).

huh. It doesn't look like that in my mail reader.
I have
struct passwd...
+ char *email;

Quoted 7 lines
Quoted 4 lines

and the patch applied cleanly when I saved the email and applied it using git-am

cat git_email.patch | git-am

Yes, it applies cleanly. But it has 8 spaces before "char *email", not a tab (otherwise it would be lined up with "struct passwd").

Ahh. I have expandtab set in .vimrc
This wouldn't happen to be part of the war on white space? converting spaces to tabs where applicable?

Is the recommended tab stop 8 characters as it is for linux? or 4?

-brandon

#5 lore raw
Quoted 3 lines · Brandon Casey

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.

#6 lore raw
Quoted 8 lines · Alex Riesen
Quoted 3 lines · Brandon Casey

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.

tab isn't 8 spaces. a tab is a tab.
It's usually *APPEARING* at 8 spaces. they *may* appears as a different size (to fit anyone preferences), as long as they stay as a tab (not expanded), and that nobody is aligning on tabs.

=> this way the how many spaces should indentation be has no meaning
since everybody can choose it on their own terminal/display without setting any value across readers of the code.

Cheers,

Signature · 1 line
Vincent Hanquez
#7 lore raw
Quoted 11 lines · Vincent Hanquez
Quoted 8 lines · Alex Riesen
Quoted 3 lines · Brandon Casey

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.

tab isn't 8 spaces. a tab is a tab.

Of course. It is used to indent the text to the next position which multiple of 8.

Quoted 7 lines

It's usually *APPEARING* at 8 spaces. they *may* appears as a different size (to fit anyone preferences), as long as they stay as a tab (not expanded), and that nobody is aligning on tabs.

=> this way the how many spaces should indentation be has no meaning
since everybody can choose it on their own terminal/display without setting any value across readers of the code.

The symbol in question, HT, is used to indent source in the project Git.

#8 lore raw
Quoted 6 lines · Alex Riesen
Quoted 2 lines

tab isn't 8 spaces. a tab is a tab.

Of course. It is used to indent the text to the next position which multiple of 8.

Oh, damn... Sorry everyone, for that stupid mail.
I meant to answer only to Vincent.

#9 lore raw

PATCH 1/1 Prefer $EMAIL over auto-generated user@hostname.

In reply to Alex Riesen

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.

---

Quoted 8 lines · Alex Riesen
Quoted 3 lines · Brandon Casey

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(-)
ident.c +4 -2
index 3d49608..be5efcd 100644
@@ -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;
Signature · 1 line
1.5.3.rc0.30.g114f-dirty