threads / patch / 8897

patchPrefer $EMAIL over auto-generated user@hostname.

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

## tl;dr

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

replies: 8people: 5as markdown or json

Brandon Casey· Jul 6, 2007, 15:03 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>
---
Linus Torvalds wrote:
>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(-)
Show changes to ident.c +4 −2
diff --git a/ident.c b/ident.c
index 3d49608..dc13510 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
Uwe Kleine-König· Jul 6, 2007, 15:11 UTC · re: Brandon Casey · lore

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

Hello Brandon,
Brandon Casey wrote:
>  	struct passwd *pw = NULL;
> +        char *email;
Indention error. Otherwise it looks good (just from reading the patch).

Best regards Uwe

-- 
Uwe Kleine-König

Set the I_WANT_A_BROKEN_PS environment variable to force BSD syntax ...
	-- manpage of procps
Brandon Casey· Jul 6, 2007, 15:22 UTC · re: Uwe Kleine-König · lore

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

Uwe Kleine-König wrote:
Show 6 quoted lines
> Hello Brandon,
> 
> Brandon Casey wrote:
>>  	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
Johannes Schindelin· Jul 6, 2007, 15:32 UTC · re: Brandon Casey · lore

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

Hi,
On Fri, 6 Jul 2007, Brandon Casey wrote:
Show 17 quoted lines
> Uwe Kleine-K?nig wrote:
> > Hello Brandon,
> > 
> > Brandon Casey wrote:
> >>  	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

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

Brandon Casey· Jul 6, 2007, 15:51 UTC · re: Johannes Schindelin · lore

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

Johannes Schindelin wrote:
Show 23 quoted lines
> Hi,
> 
> On Fri, 6 Jul 2007, Brandon Casey wrote:
> 
>> Uwe Kleine-K?nig wrote:
>>> Hello Brandon,
>>>
>>> Brandon Casey wrote:
>>>>  	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
> 
> 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
Alex Riesen· Jul 6, 2007, 15:59 UTC · re: Brandon Casey · lore

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

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.

Vincent Hanquez· Jul 6, 2007, 15:59 UTC · re: Alex Riesen · lore

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

On Fri, Jul 06, 2007 at 05:59:19PM +0200, 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.

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,
-- 
Vincent Hanquez
Alex Riesen· Jul 6, 2007, 16:22 UTC · re: Vincent Hanquez · lore

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

On 7/6/07, Vincent Hanquez <tab@snarc.org> wrote:
Show 11 quoted lines
> On Fri, Jul 06, 2007 at 05:59:19PM +0200, Alex Riesen wrote:
> > 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.
>
> 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.

Show 7 quoted 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.
Alex Riesen· Jul 6, 2007, 16:23 UTC · re: Alex Riesen · lore

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

On 7/6/07, Alex Riesen <raa.lkml@gmail.com> wrote:
Show 6 quoted 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.

← back to recent threads