ident: use full dns names to generate email addresses
[gitweb.git] / ident.c
diff --git a/ident.c b/ident.c
index 5aec073b96165654dc5ea88b0a08798fe4ada0e7..b111e34140656545bf4484aa5428d6e39ca4a7d1 100644 (file)
--- a/ident.c
+++ b/ident.c
@@ -65,23 +65,18 @@ static void add_domainname(struct strbuf *out)
 {
        char buf[1024];
        struct hostent *he;
-       const char *domainname;
 
        if (gethostname(buf, sizeof(buf))) {
                warning("cannot get host name: %s", strerror(errno));
                strbuf_addstr(out, "(none)");
                return;
        }
-       strbuf_addstr(out, buf);
        if (strchr(buf, '.'))
-               return;
-
-       he = gethostbyname(buf);
-       strbuf_addch(out, '.');
-       if (he && (domainname = strchr(he->h_name, '.')))
-               strbuf_addstr(out, domainname + 1);
+               strbuf_addstr(out, buf);
+       else if ((he = gethostbyname(buf)) && strchr(he->h_name, '.'))
+               strbuf_addstr(out, he->h_name);
        else
-               strbuf_addstr(out, "(none)");
+               strbuf_addf(out, "%s.(none)", buf);
 }
 
 static void copy_email(const struct passwd *pw, struct strbuf *email)