threads / discuss / 8882

Email address from username and hostname preferred over $EMAIL

Subject: Email address from username and hostname preferred over $EMAIL

## tl;dr

8 messages between Jul 5, 2007 and Jul 6, 2007.

replies: 7people: 6as markdown or json

mkraai@beckman.com· Jul 5, 2007, 17:57 UTC · lore
Howdy,

Git prefers to use an email address constructed from the username and hostname to the value of the EMAIL environment variable. I think it should prefer the latter to the former. This problem was introduced by ec563e8153cba89728a271a26c8a94e7a42d8152.

-- 
Matt

The server made the following annotations 
---------------------------------------------------------------------------------
This message contains information that may be privileged or confidential and is the property of Beckman Coulter, Inc. It is intended only for the person to whom it is addressed. If you are not the intended recipient, you are not authorized to read, print, retain, copy, disseminate, distribute or use this message or any part thereof. If you receive this message in error, please notify the sender immediately and delete all copies of this message.

---------------------------------------------------------------------------------
Pierre Habouzit· Jul 5, 2007, 20:21 UTC · re: mkraai@beckman.com · lore

Re: Email address from username and hostname preferred over $EMAIL

On Thu, Jul 05, 2007 at 10:57:37AM -0700, mkraai@beckman.com wrote:
Show 6 quoted lines
> Howdy,
> 
> Git prefers to use an email address constructed from the username and 
> hostname to the value of the EMAIL environment variable.  I think it 
> should prefer the latter to the former.  This problem was introduced by 
> ec563e8153cba89728a271a26c8a94e7a42d8152.
  no, ec563e8153cba89728a271a26c8a94e7a42d8152 is about making the
emails and usernames be taken from EMAIL iff there is none specified in
the different .gitconfig's (which is sane as $EMAIL is a system wide
default setting and that .git/config is definitely meant as an ovveride
of that setting).
-- 
·O·  Pierre Habouzit
··O                                                madcoder@debian.org
OOO                                                http://www.madism.org
mkraai@beckman.com· Jul 5, 2007, 20:48 UTC · re: Pierre Habouzit · lore

Re: Email address from username and hostname preferred over $EMAIL

Yes, ec563e8153cba89728a271a26c8a94e7a42d8152 made user.email take precedence over $EMAIL, but it also made the constructed email address take precedence over $EMAIL. It made fmt_ident prefer git_default_email to $EMAIL, and git_default_email is set to the constructed email address by setup_ident if it's not already set by user.email.

Pierre Habouzit <madcoder@debian.org> 07/05/2007 01:21 PM

To
mkraai@beckman.com
cc
git@vger.kernel.org
Subject
Re: Email address from username and hostname preferred over $EMAIL
On Thu, Jul 05, 2007 at 10:57:37AM -0700, mkraai@beckman.com wrote:
Show 6 quoted lines
> Howdy,
> 
> Git prefers to use an email address constructed from the username and 
> hostname to the value of the EMAIL environment variable.  I think it 
> should prefer the latter to the former.  This problem was introduced by 
> ec563e8153cba89728a271a26c8a94e7a42d8152.
  no, ec563e8153cba89728a271a26c8a94e7a42d8152 is about making the
emails and usernames be taken from EMAIL iff there is none specified in
the different .gitconfig's (which is sane as $EMAIL is a system wide
default setting and that .git/config is definitely meant as an ovveride
of that setting).
-- 
·O·  Pierre Habouzit
··O                                                madcoder@debian.org
OOO                                                http://www.madism.org


The server made the following annotations 
---------------------------------------------------------------------------------
This message contains information that may be privileged or confidential and is the property of Beckman Coulter, Inc. It is intended only for the person to whom it is addressed. If you are not the intended recipient, you are not authorized to read, print, retain, copy, disseminate, distribute or use this message or any part thereof. If you receive this message in error, please notify the sender immediately and delete all copies of this message.

---------------------------------------------------------------------------------
Linus Torvalds· Jul 5, 2007, 21:10 UTC · re: mkraai@beckman.com · lore

Re: Email address from username and hostname preferred over $EMAIL

On Thu, 5 Jul 2007, mkraai@beckman.com wrote:
Show 5 quoted lines
> 
> Git prefers to use an email address constructed from the username and 
> hostname to the value of the EMAIL environment variable.  I think it 
> should prefer the latter to the former.  This problem was introduced by 
> ec563e8153cba89728a271a26c8a94e7a42d8152.

It did that very much on purpose. "git_default_email" must take precedence, because that's the one that is filled in by the config file syntax.

So just use
	[user]
		name = ..
		email = ..

and be happy. Only in the absense of that will git start guessing, and yeah, it will not generally use EMAIL, unless it cannot get anything at all from username/hostname.

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

		Linus
Brandon Casey· Jul 6, 2007, 00:49 UTC · re: Linus Torvalds · lore

Re: Email address from username and hostname preferred over $EMAIL

Linus Torvalds wrote:
> If you want it to prefer $EMAIL, you'd need to change the initialization 
> of git_default_email, methinks.
> 
> 		Linus

I just sent an email to the list, and not in reply to this thread because I thought I read a comment about not posting a patch deep in a thread.

But, I'm thinking I should have just posted it as a reply to the thread since I quoted a portion of your message.

-brandon
Junio C Hamano· Jul 6, 2007, 01:17 UTC · re: Brandon Casey · lore

Re: Email address from username and hostname preferred over $EMAIL

Brandon Casey <casey@nrlssc.navy.mil> writes:
Show 13 quoted lines
> Linus Torvalds wrote:
>
>> If you want it to prefer $EMAIL, you'd need to change the
>> initialization of git_default_email, methinks.
>>
>> 		Linus
>
> I just sent an email to the list, and not in reply to this thread
> because I thought I read a comment about not posting a patch deep in
> a thread.
>
> But, I'm thinking I should have just posted it as a reply to the thread
> since I quoted a portion of your message.
Are Brandon Casey and Matt Kraai the same person?

I do not mind threadedness of the patch too much, but the patch recently posted by the latter does not have any description other than the title.

Other than that, I think the change itself seems sane.
Brandon Casey· Jul 6, 2007, 15:02 UTC · re: Junio C Hamano · lore

Re: Email address from username and hostname preferred over $EMAIL

Junio C Hamano wrote:
> Brandon Casey <casey@nrlssc.navy.mil> writes:
> Are Brandon Casey and Matt Kraai the same person?

heh, no. :) I see now that my patch did not make it. I tried to use git-send-email on my system and it successfully delivered to my imap mailbox, but failed delivering to the other recipients.

> I do not mind threadedness of the patch too much
ok.
Show 5 quoted lines
> , but the patch
> recently posted by the latter does not have any description
> other than the title.
> 
> Other than that, I think the change itself seems sane.

I'll go ahead and post my patch again since I think it is a little simpler and I like it better (imagine that :)

But it's such a simple fix it will be just an exercise for me.
-brandon
Josh Triplett· Jul 6, 2007, 03:44 UTC · re: Linus Torvalds · lore

Re: Email address from username and hostname preferred over $EMAIL

Linus Torvalds wrote:
Show 22 quoted lines
> On Thu, 5 Jul 2007, mkraai@beckman.com wrote:
>> Git prefers to use an email address constructed from the username and 
>> hostname to the value of the EMAIL environment variable.  I think it 
>> should prefer the latter to the former.  This problem was introduced by 
>> ec563e8153cba89728a271a26c8a94e7a42d8152.
> 
> It did that very much on purpose. "git_default_email" must take 
> precedence, because that's the one that is filled in by the config file 
> syntax.
> 
> So just use
> 
> 	[user]
> 		name = ..
> 		email = ..
> 
> and be happy. Only in the absense of that will git start guessing, and 
> yeah, it will not generally use EMAIL, unless it cannot get anything at 
> all from username/hostname.
> 
> If you want it to prefer $EMAIL, you'd need to change the initialization 
> of git_default_email, methinks.

When I originally wrote the patch, I did so intending that $EMAIL would always override git's guess of user@hostname. I set GIT_{AUTHOR,COMMITTER}_EMAIL in my environment specifically so that git would stop using guesses like josh@josh-mobile and start using my actual email address. I submitted the $EMAIL patch in hopes that eventually I could stop setting the git-specific email addresses and just set $EMAIL, which I already do for other tools. In order for that to work, $EMAIL should always override git's guesses.

- Josh Triplett

← back to recent threads