summary | shortlog | log | commit | commitdiff | tree
raw | patch | inline | side by side (parent: 4eba0f3)
raw | patch | inline | side by side (parent: 4eba0f3)
author | Petr Baudis <pasky@suse.cz> | |
Fri, 21 Oct 2005 01:57:39 +0000 (03:57 +0200) | ||
committer | Junio C Hamano <junkio@cox.net> | |
Fri, 21 Oct 2005 05:32:07 +0000 (22:32 -0700) |
Currently, the code would use getdomainname() call, which however returns
something usually unset and not necessarily related at all to the DNS
domain name (it seems to be mostly some scary NIS/YP thing).
This patch changes the code to actually use the DNS domain name, which is
also what tends to be used in emails, and we aim at emails with our ident
code.
Signed-off-by: Petr Baudis <pasky@suse.cz>
Signed-off-by: Junio C Hamano <junkio@cox.net>
something usually unset and not necessarily related at all to the DNS
domain name (it seems to be mostly some scary NIS/YP thing).
This patch changes the code to actually use the DNS domain name, which is
also what tends to be used in emails, and we aim at emails with our ident
code.
Signed-off-by: Petr Baudis <pasky@suse.cz>
Signed-off-by: Junio C Hamano <junkio@cox.net>
ident.c | patch | blob | history |
index 06d0e6cbd381f1598ba39a7fbfc7602249f60b11..bc89e1d04c63563c051005754a50247f22256974 100644 (file)
--- a/ident.c
+++ b/ident.c
#include "cache.h"
#include <pwd.h>
+#include <netdb.h>
static char git_default_date[50];
git_default_email[len++] = '@';
gethostname(git_default_email + len, sizeof(git_default_email) - len);
if (!strchr(git_default_email+len, '.')) {
+ struct hostent *he = gethostbyname(git_default_email + len);
+ char *domainname;
+
len = strlen(git_default_email);
git_default_email[len++] = '.';
- getdomainname(git_default_email+len, sizeof(git_default_email)-len);
+ if (he && (domainname = strchr(he->h_name, '.')))
+ strncpy(git_default_email + len, domainname + 1, sizeof(git_default_email) - len);
+ else
+ strncpy(git_default_email + len, "(none)", sizeof(git_default_email) - len);
+ git_default_email[sizeof(git_default_email) - 1] = 0;
}
/* And set the default date */
datestamp(git_default_date, sizeof(git_default_date));