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

9 messages from 2007-07-06 to 2007-07-06. Participants: Brandon Casey, Uwe Kleine-König, Johannes Schindelin, Alex Riesen, Vincent Hanquez.
Thread: https://gitlist.dev/t/8897

## Brandon Casey, 2007-07-06 15:03

Subject: [PATCH] Prefer $EMAIL over auto-generated user@hostname.
Message-ID: <468E59B3.7080007@nrlssc.navy.mil>
URL: https://gitlist.dev/e/468E59B3.7080007%40nrlssc.navy.mil

```

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(-)

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, 2007-07-06 15:11

Subject: Re: [PATCH] Prefer $EMAIL over auto-generated user@hostname.
Message-ID: <20070706151145.GA15341@informatik.uni-freiburg.de>
URL: https://gitlist.dev/e/20070706151145.GA15341%40informatik.uni-freiburg.de
In-Reply-To: <468E59B3.7080007@nrlssc.navy.mil>

```
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, 2007-07-06 15:22

Subject: Re: [PATCH] Prefer $EMAIL over auto-generated user@hostname.
Message-ID: <468E5E31.8040504@nrlssc.navy.mil>
URL: https://gitlist.dev/e/468E5E31.8040504%40nrlssc.navy.mil
In-Reply-To: <20070706151145.GA15341@informatik.uni-freiburg.de>

```
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

-brandon

```

## Johannes Schindelin, 2007-07-06 15:32

Subject: Re: [PATCH] Prefer $EMAIL over auto-generated user@hostname.
Message-ID: <Pine.LNX.4.64.0707061631560.4093@racer.site>
URL: https://gitlist.dev/e/Pine.LNX.4.64.0707061631560.4093%40racer.site
In-Reply-To: <468E5E31.8040504@nrlssc.navy.mil>

```
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").

Hth,
Dscho

```

## Brandon Casey, 2007-07-06 15:51

Subject: Re: [PATCH] Prefer $EMAIL over auto-generated user@hostname.
Message-ID: <468E64F9.9080805@nrlssc.navy.mil>
URL: https://gitlist.dev/e/468E64F9.9080805%40nrlssc.navy.mil
In-Reply-To: <Pine.LNX.4.64.0707061631560.4093@racer.site>

```
Johannes Schindelin wrote:
> 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

```

## Vincent Hanquez, 2007-07-06 15:59

Subject: Re: [PATCH] Prefer $EMAIL over auto-generated user@hostname.
Message-ID: <20070706155902.GA17489@snarc.org>
URL: https://gitlist.dev/e/20070706155902.GA17489%40snarc.org
In-Reply-To: <81b0412b0707060859u6a1c3a24p4399a71d84038615@mail.gmail.com>

```
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.
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, 2007-07-06 15:59

Subject: Re: [PATCH] Prefer $EMAIL over auto-generated user@hostname.
Message-ID: <81b0412b0707060859u6a1c3a24p4399a71d84038615@mail.gmail.com>
URL: https://gitlist.dev/e/81b0412b0707060859u6a1c3a24p4399a71d84038615%40mail.gmail.com
In-Reply-To: <468E64F9.9080805@nrlssc.navy.mil>

```
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.

```

## Alex Riesen, 2007-07-06 16:22

Subject: Re: [PATCH] Prefer $EMAIL over auto-generated user@hostname.
Message-ID: <81b0412b0707060922sf0e3c17wcbd55dd65e1c1e14@mail.gmail.com>
URL: https://gitlist.dev/e/81b0412b0707060922sf0e3c17wcbd55dd65e1c1e14%40mail.gmail.com
In-Reply-To: <20070706155902.GA17489@snarc.org>

```
On 7/6/07, Vincent Hanquez <tab@snarc.org> wrote:
> 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.

> 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, 2007-07-06 16:23

Subject: Re: [PATCH] Prefer $EMAIL over auto-generated user@hostname.
Message-ID: <81b0412b0707060923j189f876v96b2c5cd92fd1734@mail.gmail.com>
URL: https://gitlist.dev/e/81b0412b0707060923j189f876v96b2c5cd92fd1734%40mail.gmail.com
In-Reply-To: <81b0412b0707060922sf0e3c17wcbd55dd65e1c1e14@mail.gmail.com>

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

```
