ident: use full dns names to generate email addresses
commitf8254d321cc42a6d47abf79b0f93d16e28432df3
authorJeff King <peff@peff.net>
Mon, 21 May 2012 23:10:23 +0000 (21 19:10 -0400)
committerJunio C Hamano <gitster@pobox.com>
Tue, 22 May 2012 16:08:46 +0000 (22 09:08 -0700)
tree371480fb0944b3f7632871ebb0093559da0968d2
parent2f70587502b6b5a8cfda5a3eff54392f48e2db8d
ident: use full dns names to generate email addresses

When we construct an email address from the username and
hostname, we generate the host part of the email with this
procedure:

  1. add the result of gethostname

  2. if it has a dot, ok, it's fully qualified

  3. if not, then look up the unqualified hostname via
     gethostbyname; take the domain name of the result and
     append it to the hostname

Step 3 can actually produce a bogus result, as the name
returned by gethostbyname may not be related to the hostname
we fed it (e.g., consider a machine "foo" with names
"foo.one.example.com" and "bar.two.example.com"; we may have
the latter returned and generate the bogus name
"foo.two.example.com").

This patch simply uses the full hostname returned by
gethostbyname. In the common case that the first part is the
same as the unqualified hostname, the behavior is identical.
And in the case that it is not the same, we are much more
likely to be generating a valid name.

Signed-off-by: Jeff King <peff@peff.net>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
ident.c